Add a com.twitter.finatra.http.exceptions.ExceptionMapper by type T
Add a com.twitter.finatra.http.exceptions.ExceptionMapper by type T
- ExceptionMapper type T which should subclass com.twitter.finatra.http.exceptions.ExceptionMapper
Add a collection of com.twitter.finatra.http.exceptions.ExceptionMapper as defined by a com.twitter.finatra.http.exceptions.ExceptionMapperCollection.
Add a collection of com.twitter.finatra.http.exceptions.ExceptionMapper as defined by a com.twitter.finatra.http.exceptions.ExceptionMapperCollection. The collection is iterated over and each mapper contained therein is added. If a mapper has already been added for the given type T in ExceptionMapper[T], it will be replaced.
- com.twitter.finatra.http.exceptions.ExceptionMapperCollection to add.
Add a com.twitter.finatra.http.exceptions.ExceptionMapper over type T to the manager.
Add a com.twitter.finatra.http.exceptions.ExceptionMapper over type T to the manager. If a mapper has already been added for the given T, it will be replaced.
- exception class type which should subclass java.lang.Throwable
- com.twitter.finatra.http.exceptions.ExceptionMapper to add
Returns a com.twitter.finagle.http.Response as computed by the matching com.twitter.finatra.http.exceptions.ExceptionMapper to the given throwable.
Returns a com.twitter.finagle.http.Response as computed by the matching com.twitter.finatra.http.exceptions.ExceptionMapper to the given throwable.
- a com.twitter.finagle.http.Request
- java.lang.Throwable to match against registered ExceptionMappers.
a com.twitter.finagle.http.Response
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.
com.twitter.finatra.http.internal.exceptions.ThrowableExceptionMapper Note: When searching for the parent exception mapper, it would be nice to traverse the entire class linearization so it works for traits/mixins too [1]. Unfortunately, implementing this would require a lot more reflection and it might not be threadsafe [2]. Doing it in Scala 2.11 might be easier and safer. [1] https://stackoverflow.com/questions/15623498/handy-ways-to-show-linearization-of-a-class [2] https://docs.scala-lang.org/overviews/reflection/thread-safety.html