class DomainServiceExceptionMapper implements ExceptionMapper<DomainServiceException> {

    @Override
    public Response toResponse(DomainServiceException exception) {
        final int status = this.status.get(exception.getClass());
        return Response.status(status)
                .type(MediaType.APPLICATION_JSON_TYPE)
                .entity(new ErrorMessage(status, exception.getMessage()))
                .build();
    }

    @Inject public  DomainServiceExceptionMapper();

}