2121
2222package com .jaspersoft .jasperserver .jaxrs .client .core .exceptions .handling ;
2323
24- import com . jaspersoft . jasperserver . jaxrs . client . core .enums . ResponseStatus ;
24+ import javax . ws . rs . core .Response . Status ;
2525import com .jaspersoft .jasperserver .jaxrs .client .core .exceptions .AccessDeniedException ;
2626import com .jaspersoft .jasperserver .jaxrs .client .core .exceptions .AuthenticationFailedException ;
2727import com .jaspersoft .jasperserver .jaxrs .client .core .exceptions .BadRequestException ;
@@ -46,17 +46,17 @@ public class DefaultErrorHandler implements ErrorHandler {
4646
4747// private static final Log log = LogFactory.getLog(DefaultErrorHandler.class);
4848
49- protected static final Map <Integer , Class <? extends JSClientWebException >> httpErrorCodeToTypeMap =
50- new HashMap <Integer , Class <? extends JSClientWebException >>() {{
51- put (ResponseStatus .BAD_REQUEST , BadRequestException .class );
52- put (ResponseStatus .FORBIDDEN , AccessDeniedException .class );
53- put (ResponseStatus . NOT_ALLOWED , HttpMethodNotAllowedException .class );
54- put (ResponseStatus . SERVER_ERROR , InternalServerErrorException .class );
55- put (ResponseStatus .NOT_ACCEPTABLE , RequestedRepresentationNotAvailableForResourceException .class );
56- put (ResponseStatus .NOT_FOUND , ResourceNotFoundException .class );
57- put (ResponseStatus .UNAUTHORIZED , AuthenticationFailedException .class );
58- put (ResponseStatus .CONFLICT , ConflictException .class );
59- put (ResponseStatus . UNSUPPORTED_TYPE , RepresentationalTypeNotSupportedForResourceException .class );
49+ protected static final Map <Response . Status , Class <? extends JSClientWebException >> httpErrorCodeToTypeMap =
50+ new HashMap <Response . Status , Class <? extends JSClientWebException >>() {{
51+ put (Status .BAD_REQUEST , BadRequestException .class );
52+ put (Status .FORBIDDEN , AccessDeniedException .class );
53+ put (Status . NOT_ACCEPTABLE , HttpMethodNotAllowedException .class );
54+ put (Status . INTERNAL_SERVER_ERROR , InternalServerErrorException .class );
55+ put (Status .NOT_ACCEPTABLE , RequestedRepresentationNotAvailableForResourceException .class );
56+ put (Status .NOT_FOUND , ResourceNotFoundException .class );
57+ put (Status .UNAUTHORIZED , AuthenticationFailedException .class );
58+ put (Status .CONFLICT , ConflictException .class );
59+ put (Status . UNSUPPORTED_MEDIA_TYPE , RepresentationalTypeNotSupportedForResourceException .class );
6060 }};
6161
6262 @ Override
@@ -104,7 +104,7 @@ protected void handleBodyError(Response response) {
104104 }
105105
106106 protected void handleStatusCodeError (Response response , String overridingMessage ) {
107- Class <? extends JSClientWebException > exceptionType = httpErrorCodeToTypeMap .get (response .getStatus ());
107+ Class <? extends JSClientWebException > exceptionType = httpErrorCodeToTypeMap .get (Response . Status . fromStatusCode ( response .getStatus () ));
108108 String reasonPhrase = response .getStatusInfo ().getReasonPhrase ();
109109 JSClientWebException exception = new JSClientWebException (overridingMessage != null ? overridingMessage : reasonPhrase );
110110 try {
0 commit comments