use of com.b2international.snowowl.fhir.core.exceptions.FhirException in project snow-owl by b2ihealthcare.
the class AbstractFhirController method handle.
/**
* Generic <b>Internal Server Error</b> exception handler, serving as a fallback for RESTful client calls.
*
* @param ex
* @return {@link OperationOutcome} instance with detailed messages
*/
@ExceptionHandler
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ResponseBody
public OperationOutcome handle(final Exception ex) {
if (Throwables.getRootCause(ex).getMessage().toLowerCase().contains("broken pipe")) {
// socket is closed, cannot return any response
return null;
} else {
LOG.error("Exception during processing of a request", ex);
FhirException fhirException = FhirException.createFhirError(GENERIC_USER_MESSAGE + " Exception: " + ex.getMessage(), OperationOutcomeCode.MSG_BAD_SYNTAX);
return fhirException.toOperationOutcome();
}
}
use of com.b2international.snowowl.fhir.core.exceptions.FhirException in project snow-owl by b2ihealthcare.
the class AbstractFhirController method handle.
/**
* Exception handler converting any {@link JsonMappingException} to an <em>HTTP 400</em>.
*
* @param ex
* @return {@link OperationOutcome} instance with detailed messages
*/
@ExceptionHandler
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody
public OperationOutcome handle(HttpMessageNotReadableException ex) {
LOG.trace("Exception during processing of a JSON document", ex);
FhirException fhirException = FhirException.createFhirError(GENERIC_USER_MESSAGE + " Exception: " + ex.getMessage(), OperationOutcomeCode.MSG_CANT_PARSE_CONTENT);
return fhirException.toOperationOutcome();
}
use of com.b2international.snowowl.fhir.core.exceptions.FhirException in project snow-owl by b2ihealthcare.
the class AbstractFhirController method handle.
@ExceptionHandler
@ResponseStatus(HttpStatus.UNAUTHORIZED)
@ResponseBody
public ResponseEntity<OperationOutcome> handle(final UnauthorizedException ex) {
FhirException fhirException = FhirException.createFhirError(ex.getMessage(), OperationOutcomeCode.MSG_AUTH_REQUIRED);
OperationOutcome body = fhirException.toOperationOutcome();
HttpHeaders headers = new HttpHeaders();
headers.add("WWW-Authenticate", "Basic");
headers.add("WWW-Authenticate", "Bearer");
return new ResponseEntity<>(body, headers, HttpStatus.UNAUTHORIZED);
}
Aggregations