org.springframework.web.client.HttpClientErrorException#getLocalizedMessage ( )源码实例Demo

下面列出了org.springframework.web.client.HttpClientErrorException#getLocalizedMessage ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: xxproject   文件: CustomRestExceptionHandler.java
@ExceptionHandler({ OAuth2Exception.class })
public ResponseEntity<Object> handleOAuth2Exception(HttpClientErrorException ex, WebRequest request) {
    final String error = "Digits oauth authorization failed" ;
    final ApiError apiError = new ApiError(HttpStatus.FORBIDDEN, ex.getLocalizedMessage(), error);

    return new ResponseEntity<Object>(apiError, new HttpHeaders(), HttpStatus.FORBIDDEN);
}
 
源代码2 项目: xxproject   文件: CustomRestExceptionHandler.java
@ExceptionHandler({ AccessDeniedException.class })
public ResponseEntity<Object> handleAccessDeniedException(HttpClientErrorException ex, WebRequest request) {
    final String error = "Digits access authorization failed" ;
    final ApiError apiError = new ApiError(HttpStatus.FORBIDDEN, ex.getLocalizedMessage(), error);

    return new ResponseEntity<Object>(apiError, new HttpHeaders(), HttpStatus.FORBIDDEN);
}
 
源代码3 项目: data-prep   文件: GlobalExceptionHandler.java
@ExceptionHandler({ HttpClientErrorException.class })
public ResponseEntity<TdpExceptionDto> handleError(HttpClientErrorException e) {

    HttpHeaders httpHeaders = new HttpHeaders();
    httpHeaders.setContentType(MediaType.APPLICATION_JSON_UTF8);

    String code = e.getStatusCode().toString();
    String message = e.getMessage();
    String localizedMessage = e.getLocalizedMessage();
    String statusText = e.getStatusText();

    TdpExceptionDto exceptionDto = new TdpExceptionDto(code, null, message, localizedMessage, statusText, null);

    return new ResponseEntity<>(exceptionDto, httpHeaders, e.getStatusCode());
}