use of org.sklsft.commons.api.exception.ErrorReport in project skeleton-commons by skeleton-software-community.
the class ErrorReportHandler method handleError.
/*
* (non-Javadoc)
* @see org.springframework.web.client.ResponseErrorHandler#handleError(org.springframework.http.client.ClientHttpResponse)
*/
@Override
public void handleError(ClientHttpResponse response) throws IOException {
ErrorReport errorReport = objectMapper.readValue(response.getBody(), ErrorReport.class);
convertErrorReport(errorReport);
}
use of org.sklsft.commons.api.exception.ErrorReport in project skeleton-commons by skeleton-software-community.
the class ErrorReportHandlerTest method testApplicationExceptionDummyDetails.
@Test
public void testApplicationExceptionDummyDetails() throws JsonProcessingException {
String message = "test";
Dummy dummy = new Dummy(1L, "test");
ErrorReport errorReport = new ErrorReport();
errorReport.setExceptionClassName(TestException.class.getName());
errorReport.setMessage(message);
errorReport.setDetails(dummy);
try {
errorReportHandler.convertErrorReport(errorReport);
} catch (ApplicationException e) {
Assert.assertEquals(e.getMessage(), message);
Assert.assertTrue(e instanceof TestException);
Assert.assertTrue(e.getDetails().equals(dummy));
return;
}
Assert.fail();
}
use of org.sklsft.commons.api.exception.ErrorReport in project skeleton-commons by skeleton-software-community.
the class RestExceptionHandler method handleException.
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(Exception.class)
@ResponseBody
public ErrorReport handleException(Exception e) {
logger.error("exception thrown : " + e.getMessage(), e);
ErrorReport errorReport = new ErrorReport();
errorReport.setExceptionClassName(TechnicalError.class.getName());
errorReport.setMessage(ApplicationException.ERROR_UNKNOWN);
return errorReport;
}
use of org.sklsft.commons.api.exception.ErrorReport in project skeleton-commons by skeleton-software-community.
the class RestExceptionHandlerTest method testApplicationExceptionNoDetails.
@Test
public void testApplicationExceptionNoDetails() {
String message = "test";
ApplicationException e = new TestException(message);
ErrorReport errorReport = restExceptionHandler.handleApplicationException(e);
Assert.assertEquals(errorReport.getMessage(), message);
Assert.assertTrue(errorReport.getExceptionClassName().equals(TestException.class.getName()));
Assert.assertNull(errorReport.getDetails());
}
use of org.sklsft.commons.api.exception.ErrorReport in project skeleton-commons by skeleton-software-community.
the class ErrorReportHandlerTest method testApplicationExceptionNoDetails.
@Test
public void testApplicationExceptionNoDetails() throws JsonProcessingException {
String message = "test";
ErrorReport errorReport = new ErrorReport();
errorReport.setExceptionClassName(TestException.class.getName());
errorReport.setMessage(message);
try {
errorReportHandler.convertErrorReport(errorReport);
} catch (ApplicationException e) {
Assert.assertEquals(e.getMessage(), message);
Assert.assertTrue(e instanceof TestException);
Assert.assertNull(e.getDetails());
return;
}
Assert.fail();
}
Aggregations