class RuntimeExceptionUnwrappingMapper implements ExceptionMapper<RuntimeException> {

    @Override
    public Response toResponse(RuntimeException exception) {
        Throwable cause = exception.getCause();
        if (cause instanceof DomainServiceException) {
            return domainServiceExceptionMapper.toResponse((DomainServiceException) cause);
        }
        int status = HttpStatus.INTERNAL_SERVER_ERROR_500;
        return Response.status(status)
                .type(MediaType.APPLICATION_JSON)
                .entity(new ErrorMessage(status, exception.getMessage()))
                .build();
    }

    @Inject public  RuntimeExceptionUnwrappingMapper(DomainServiceExceptionMapper domainServiceExceptionMapper);

}