Package

com.twitter.finatra.http

exceptions

Permalink

package exceptions

Visibility
  1. Public
  2. All

Type Members

  1. abstract class AbstractExceptionMapper[T <: Throwable] extends ExceptionMapper[T]

    Permalink

    AbstractExceptionMapper for usage from Java

  2. case class BadRequestException(mediaType: String, errors: Seq[String]) extends HttpException with Product with Serializable

    Permalink
  3. case class ConflictException(mediaType: String, errors: Seq[String]) extends HttpException with Product with Serializable

    Permalink
  4. class ExceptionManager extends AnyRef

    Permalink

    A class to register com.twitter.finatra.http.exceptions.ExceptionMappers and handle exceptions.

    A class to register com.twitter.finatra.http.exceptions.ExceptionMappers and handle exceptions.

    Given an exception, the ExceptionManager will find an com.twitter.finatra.http.exceptions.ExceptionMapper to handle that particular class of exceptions. If the mapper for that exception isn't registered, the ExceptionManager will try the exception's parent class, and so on, until it reaches the Throwable class. The framework registers a "root" exception mapper over Throwable which will eventually be invoked. Users are free to register their own ExceptionMapper[Throwable] which overrides the "root" exception mapper.

    Annotations
    @Singleton()
    See also

    com.twitter.finatra.http.internal.exceptions.ThrowableExceptionMapper

  5. trait ExceptionMapper[T <: Throwable] extends AnyRef

    Permalink

    An ExceptionMapper converts a T-typed throwable to an HTTP response.

    An ExceptionMapper converts a T-typed throwable to an HTTP response.

    Java users should use the AbstractExceptionMapper.

  6. class ExceptionMapperCollection extends Traversable[Manifest[ExceptionMapper[_]]]

    Permalink

    Represents a collection of com.twitter.finatra.http.exceptions.ExceptionMappers which is a

    Represents a collection of com.twitter.finatra.http.exceptions.ExceptionMappers which is a

    Traversable[Manifest[ExceptionMapper[_]]]

    .

    Traversable[Manifest[ExceptionMapper[_]]] }}}

  7. case class ForbiddenException(mediaType: String, errors: Seq[String]) extends HttpException with Product with Serializable

    Permalink
  8. class HttpException extends Exception

    Permalink

    An Exception which will be rendered as an HTTP response.

  9. class HttpNackException extends Exception with NoStackTrace

    Permalink
  10. class HttpResponseException extends Exception with NonRetryableException with NoStackTrace

    Permalink
  11. case class InternalServerErrorException(mediaType: String, errors: Seq[String]) extends HttpException with Product with Serializable

    Permalink
  12. class MaxForwardsExceededException extends Exception

    Permalink

    Denotes that Controller forwarding exceeded the maximum depth.

    Denotes that Controller forwarding exceeded the maximum depth.

    See also

    com.twitter.finatra.http.HttpRouter#withMaxRequestForwardingDepth

    com.twitter.finatra.http.HttpForward

  13. case class MethodNotAllowedException(mediaType: String, errors: Seq[String]) extends HttpException with Product with Serializable

    Permalink
  14. case class NotAcceptableException(mediaType: String, errors: Seq[String]) extends HttpException with Product with Serializable

    Permalink
  15. case class NotFoundException(mediaType: String, errors: Seq[String]) extends HttpException with Product with Serializable

    Permalink
  16. class RouteParamExtractionException extends Exception with NoStackTrace

    Permalink

    Used to denote an exception which occurred during routing while attempting to extract the capture value of a route param from an incoming request URI, e.g., for a defined route: /user/:id, extracting the text "123" from an incoming request URI of /user/123.

    Used to denote an exception which occurred during routing while attempting to extract the capture value of a route param from an incoming request URI, e.g., for a defined route: /user/:id, extracting the text "123" from an incoming request URI of /user/123.

    This exception is handled by the framework but is public to allow users to customize their server behavior via an installed ExceptionMapper over this exception type, if desired. Note, that this exception occurs **before** routing and thus any user-defined ExceptionMapper should be added to an ExceptionManager installed on an com.twitter.finatra.http.filters.ExceptionMappingFilter that is installed with beforeRouting = true.

    class RouteParamExtractionExceptionMapper
      extends ExceptionMapper[RouteParamExtractionException] {
      def toResponse(request: Request, throwable: RouteParamExtractionException): Response  = ???
    }
    
    ...
    
    val beforeRoutingExceptionManager: ExceptionManager =
      new ExceptionManager(injector, injector.instance[StatsReceiver])
    
    beforeRoutingExceptionManager.add[RouteParamExtractionExceptionMapper]
    
    ...
    
    override def configureHttp(router: HttpRouter) {
      router
        .filter(new ExceptionMappingFilter[Request](beforeRoutingExceptionManager), beforeRouting = true)
        .add[MyAPIController]
    }
    
    // or without a custom `ExceptionManager` (uses the default configured by the `ExceptionManagerModule`):
    
    override def configureHttp(router: HttpRouter) {
     router
       .filter[ExceptionMappingFilter[Request]](beforeRouting = true)
       .add[MyAPIController]
       .exceptionMapper[RouteParamExtractionExceptionMapper]
     }
  17. case class ServiceUnavailableException(mediaType: String, errors: Seq[String]) extends HttpException with Product with Serializable

    Permalink
  18. class UnsupportedMethodException extends Exception with NoStackTrace

    Permalink

    Used to denote that an incoming request HTTP method (verb) is not supported by a matched route (that is a route exists which matches the incoming request URI but is not defined over the incoming request method).

    Used to denote that an incoming request HTTP method (verb) is not supported by a matched route (that is a route exists which matches the incoming request URI but is not defined over the incoming request method).

    This exception is handled by the framework but is public to allow users to customize their server behavior via an installed ExceptionMapper over this exception type, if desired. Note, that this exception occurs **before** routing and thus any user-defined ExceptionMapper should be added to an ExceptionManager installed on an com.twitter.finatra.http.filters.ExceptionMappingFilter that is installed with beforeRouting = true.

    class UnsupportedMethodExceptionMapper
      extends ExceptionMapper[UnsupportedMethodException] {
      def toResponse(request: Request, throwable: UnsupportedMethodException): Response  = ???
    }
    
    ...
    
    val beforeRoutingExceptionManager: ExceptionManager =
      new ExceptionManager(injector, injector.instance[StatsReceiver])
    
    beforeRoutingExceptionManager.add[UnsupportedMethodException]
    
    ...
    
    override def configureHttp(router: HttpRouter) {
      router
        .filter(new ExceptionMappingFilter[Request](beforeRoutingExceptionManager), beforeRouting = true)
        .add[MyAPIController]
    }
    
    // or without a custom `ExceptionManager` (uses the default configured by the `ExceptionManagerModule`):
    
    override def configureHttp(router: HttpRouter) {
     router
       .filter[ExceptionMappingFilter[Request]](beforeRouting = true)
       .add[MyAPIController]
       .exceptionMapper[UnsupportedMethodExceptionMapper]
     }

Ungrouped