I am developing a webapp that provides a number of REST endpoints with Google Sitebricks. To minimize duplicate/similar code I would like to configure sitebricks to respond with a consistent Reply object every time the code executed in the REST endpoints throws an exception.
Instead of handling the exceptions and creating a custom JSON response in each endpoint I want that sitebricks itself catches the exception and returns something like:
{
statusCode: 123,
message: "this could contain Exception.getMessage()",
stacktrace: "this could contain the full stacktrace"
}
Sitebricks would then be responsible to create the above structure and fill in the status code and other fields e.g. based on an annotation.
- Do I have to build this myself or did somebody else already do that? Maybe there even is a way to do this with Sitebricks itself?
- Is there an equivalent to Jersey's ExceptionMapper interface?