use of org.sklsft.commons.api.exception.ErrorReport in project skeleton-commons by skeleton-software-community.
the class RestExceptionHandler method handleApplicationException.
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(ApplicationException.class)
@ResponseBody
public ErrorReport handleApplicationException(ApplicationException e) {
logger.error("exception thrown : " + e.getMessage(), e);
ErrorReport errorReport = new ErrorReport();
errorReport.setExceptionClassName(e.getClass().getName());
errorReport.setMessage(e.getMessage());
errorReport.setDetails(e.getDetails());
return errorReport;
}
use of org.sklsft.commons.api.exception.ErrorReport in project skeleton-commons by skeleton-software-community.
the class RestExceptionHandlerTest method testApplicationExceptionDummyDetails.
@Test
public void testApplicationExceptionDummyDetails() {
Dummy dummy = new Dummy();
dummy.setLongField(1L);
dummy.setStringField("test");
String message = "test";
ApplicationException e = new TestException(message, dummy);
ErrorReport errorReport = restExceptionHandler.handleApplicationException(e);
Assert.assertEquals(errorReport.getMessage(), message);
Assert.assertTrue(errorReport.getExceptionClassName().equals(TestException.class.getName()));
Assert.assertNotNull(errorReport.getDetails());
Assert.assertTrue(errorReport.getDetails() instanceof Dummy);
}
Aggregations