use of com.faforever.api.error.ErrorResponse 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;
}
Aggregations