Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

JAXRS EXCEPTION MAPPER

@Provider 
public class PersistenceMapper implements ExceptionMapper<PersistenceException> { 

    @Override 
    public Response toResponse(PersistenceException arg0) { 
        if(arg0.getCause() instanceof InvalidDataException) {
           return Response.status(Response.Status.BAD_REQUEST).build(); 
        } else {
           ...
        }
    } 

} 
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #JAXRS #EXCEPTION #MAPPER
ADD COMMENT
Topic
Name
2+3 =