Can Lagom errors be handled using Play error handling?
No, the Play error handler is not invoked from Lagom, because the Lagom exception serializer intercepts it first. Any exception thrown by application code will be wrapped in a transport exception, serialized to json and a response is built from it. When it reaches the Play layer, the response is not considered an error anymore and the Play DefaultHttpErrorHandler
is not used. The bottom line is that Lagom does the error handling instead. This is needed in other to translate the errors between client and server and promote an RPC style API. This mechanism allows the Lagom client to "understand" the json being transferred and translate it to a TransportException
.
For custom error handling in Lagom please check out this support article, though.