Search in sources :

Example 1 with ErrorResult

use of com.faforever.api.error.ErrorResult in project faf-java-api by FAForever.

the class JsonApiOAuthMessageConverter method transformObject.

protected Object transformObject(Object object) {
    ErrorResponse response = new ErrorResponse();
    if (object instanceof OAuth2Exception) {
        OAuth2Exception oAuth2Exception = (OAuth2Exception) object;
        final ErrorResult newError = new ErrorResult(String.valueOf(oAuth2Exception.getHttpErrorCode()), oAuth2Exception.getOAuth2ErrorCode(), oAuth2Exception.getMessage());
        response.addError(newError);
        newError.setMeta(ErrorResult.createMeta(null, oAuth2Exception.getAdditionalInformation()).orElse(null));
    } else {
        response.addError(new ErrorResult(String.valueOf(HttpStatus.INTERNAL_SERVER_ERROR.value()), "Error", object.toString()));
    }
    return response;
}
Also used : ErrorResult(com.faforever.api.error.ErrorResult) OAuth2Exception(org.springframework.security.oauth2.common.exceptions.OAuth2Exception) ErrorResponse(com.faforever.api.error.ErrorResponse)

Aggregations

ErrorResponse (com.faforever.api.error.ErrorResponse)1 ErrorResult (com.faforever.api.error.ErrorResult)1 OAuth2Exception (org.springframework.security.oauth2.common.exceptions.OAuth2Exception)1