As the ExceptionHandler was static, it was impossible to change the configuration, like with stacktrace or not, on the fly.

This commit is contained in:
Sebastien Riviere 2017-04-03 14:19:03 +02:00
parent 594f6a0d3b
commit 6b2814d7f2
1 changed files with 4 additions and 6 deletions

View File

@ -64,8 +64,6 @@ public abstract class AbstractJaxRsProvider implements IRestfulServerDefaults {
private final FhirContext CTX; private final FhirContext CTX;
/** The default exception interceptor */
private static final JaxRsExceptionInterceptor DEFAULT_EXCEPTION_HANDLER = new JaxRsExceptionInterceptor();
private static final String PROCESSING = "processing"; private static final String PROCESSING = "processing";
private static final String ERROR = "error"; private static final String ERROR = "error";
@ -260,13 +258,13 @@ public abstract class AbstractJaxRsProvider implements IRestfulServerDefaults {
public Response handleException(final JaxRsRequest theRequest, final Throwable theException) public Response handleException(final JaxRsRequest theRequest, final Throwable theException)
throws IOException { throws IOException {
if (theException instanceof JaxRsResponseException) { if (theException instanceof JaxRsResponseException) {
return DEFAULT_EXCEPTION_HANDLER.convertExceptionIntoResponse(theRequest, (JaxRsResponseException) theException); return new JaxRsExceptionInterceptor().convertExceptionIntoResponse(theRequest, (JaxRsResponseException) theException);
} else if (theException instanceof DataFormatException) { } else if (theException instanceof DataFormatException) {
return DEFAULT_EXCEPTION_HANDLER.convertExceptionIntoResponse(theRequest, new JaxRsResponseException( return new JaxRsExceptionInterceptor().convertExceptionIntoResponse(theRequest, new JaxRsResponseException(
new InvalidRequestException(theException.getMessage(), createOutcome((DataFormatException) theException)))); new InvalidRequestException(theException.getMessage(), createOutcome((DataFormatException) theException))));
} else { } else {
return DEFAULT_EXCEPTION_HANDLER.convertExceptionIntoResponse(theRequest, return new JaxRsExceptionInterceptor().convertExceptionIntoResponse(theRequest,
DEFAULT_EXCEPTION_HANDLER.convertException(this, theException)); new JaxRsExceptionInterceptor().convertException(this, theException));
} }
} }