Search in sources :

Example 1 with ErrorCode

use of org.craftercms.profile.api.exceptions.ErrorCode in project profile by craftercms.

the class AbstractProfileRestClientBase method handleRestServiceException.

protected void handleRestServiceException(RestServiceException e) throws ProfileException {
    if (e.getErrorDetails() instanceof ErrorDetails) {
        ErrorDetails errorDetails = (ErrorDetails) e.getErrorDetails();
        HttpStatus responseStatus = e.getResponseStatus();
        ErrorCode errorCode = errorDetails.getErrorCode();
        String message = errorDetails.getMessage();
        throw new ProfileRestServiceException(responseStatus, errorCode, message);
    } else {
        HttpStatus responseStatus = e.getResponseStatus();
        String message = e.getErrorDetails().toString();
        throw new ProfileRestServiceException(responseStatus, message);
    }
}
Also used : ProfileRestServiceException(org.craftercms.profile.exceptions.ProfileRestServiceException) HttpStatus(org.springframework.http.HttpStatus) ErrorDetails(org.craftercms.profile.api.exceptions.ErrorDetails) ErrorCode(org.craftercms.profile.api.exceptions.ErrorCode)

Aggregations

ErrorCode (org.craftercms.profile.api.exceptions.ErrorCode)1 ErrorDetails (org.craftercms.profile.api.exceptions.ErrorDetails)1 ProfileRestServiceException (org.craftercms.profile.exceptions.ProfileRestServiceException)1 HttpStatus (org.springframework.http.HttpStatus)1