use of org.jboss.resteasy.spi.InternalServerErrorException in project candlepin by candlepin.
the class InternalServerErrorExceptionMapperTest method handleISE.
@Test
public void handleISE() {
InternalServerErrorException isee = new InternalServerErrorException("fubarred");
InternalServerErrorExceptionMapper iseem = injector.getInstance(InternalServerErrorExceptionMapper.class);
Response r = iseem.toResponse(isee);
assertEquals(500, r.getStatus());
verifyMessage(r, rtmsg("fubarred"));
}
use of org.jboss.resteasy.spi.InternalServerErrorException in project teiid by teiid.
the class TeiidRSExceptionHandler method toResponse.
@Override
public Response toResponse(Exception e) {
ResponseError error = new ResponseError();
// $NON-NLS-1$
String code = "ERROR";
if (e instanceof NotAuthorizedException) {
// $NON-NLS-1$
code = "401";
} else if (e instanceof NotFoundException) {
// $NON-NLS-1$
code = "404";
} else if (e instanceof InternalServerErrorException) {
// $NON-NLS-1$
code = "500";
} else if (e instanceof WebApplicationException) {
// $NON-NLS-1$
code = "500";
}
error.setCode(code);
error.setMessage(e.getMessage());
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
error.setDetails(sw.toString());
String type = MediaType.APPLICATION_XML;
List<MediaType> acceptTypes = httpHeaders.getAcceptableMediaTypes();
if (acceptTypes != null) {
for (MediaType acceptType : acceptTypes) {
if (isApplicationJsonWithParametersIgnored(acceptType)) {
type = MediaType.APPLICATION_JSON;
break;
}
}
}
return Response.serverError().entity(error).type(type).build();
}
Aggregations