Class AwsProxyExceptionHandler

java.lang.Object
com.amazonaws.serverless.proxy.AwsProxyExceptionHandler
All Implemented Interfaces:
ExceptionHandler<AwsProxyResponse>

public class AwsProxyExceptionHandler extends Object implements ExceptionHandler<AwsProxyResponse>
Default implementation of the ExceptionHandler object that returns AwsProxyResponse objects. Returns application/json messages with a status code of 500 when the RequestReader failed to read the incoming event or if InternalServerErrorException is thrown. For all other exceptions returns a 502. Responses are populated with a JSON object containing a message property.
See Also:
  • Field Details

    • HEADERS

      protected static final Headers HEADERS
  • Constructor Details

    • AwsProxyExceptionHandler

      public AwsProxyExceptionHandler()
  • Method Details

    • handle

      public AwsProxyResponse handle(Throwable ex)
      Description copied from interface: ExceptionHandler
      The handle method is called by the container object whenever an exception occurs in the proxy method for typed calls
      Specified by:
      handle in interface ExceptionHandler<AwsProxyResponse>
      Parameters:
      ex - The exception thrown by the application
      Returns:
      A valid response object
    • handle

      public void handle(Throwable ex, OutputStream stream) throws IOException
      Description copied from interface: ExceptionHandler
      This handle implementation is called whenever an exception occurs in the stream-based proxy method.
      Specified by:
      handle in interface ExceptionHandler<AwsProxyResponse>
      Parameters:
      ex - The exception thrown by the application
      stream - The OutputStream where the exception will be written
      Throws:
      IOException - When the exception handler fails to write to the OutputStream
    • getErrorJson

      protected String getErrorJson(String message)