use of org.jboss.resteasy.spi.ApplicationException in project stdlib by petergeneric.
the class RestFailureMarshaller method renderFailure.
/**
* Render a Throwable as a RestFailure
*
* @param e
*
* @return
*/
public RestFailure renderFailure(Throwable e) {
// Strip away ApplicationException wrappers
if (e.getCause() != null && (e instanceof ApplicationException)) {
return renderFailure(e.getCause());
}
RestFailure failure = new RestFailure();
failure.id = getOrGenerateFailureId();
failure.date = new Date();
if (e instanceof RestException) {
RestException re = (RestException) e;
failure.httpCode = re.getHttpCode();
failure.exception = renderThrowable(e);
} else {
// by default
failure.httpCode = 500;
failure.exception = renderThrowable(e);
}
return failure;
}
use of org.jboss.resteasy.spi.ApplicationException in project candlepin by candlepin.
the class ApplicationExceptionMapperTest method noCause.
@Test
public void noCause() {
ApplicationException ae = new ApplicationException("oops", null);
ApplicationExceptionMapper aem = injector.getInstance(ApplicationExceptionMapper.class);
Response r = aem.toResponse(ae);
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), r.getStatus());
verifyMessage(r, rtmsg("oops"));
}
use of org.jboss.resteasy.spi.ApplicationException in project candlepin by candlepin.
the class ApplicationExceptionMapperTest method withCause.
@Test
public void withCause() {
EOFException eofe = new EOFException("screwed");
ApplicationException ae = new ApplicationException("oops", eofe);
ApplicationExceptionMapper aem = injector.getInstance(ApplicationExceptionMapper.class);
Response r = aem.toResponse(ae);
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), r.getStatus());
verifyMessage(r, rtmsg("oops"));
}
Aggregations