Java Code Examples for org.springframework.web.context.request.WebRequest#getDescription()
The following examples show how to use
org.springframework.web.context.request.WebRequest#getDescription() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GlobalExceptionHandler.java From hesperides with GNU General Public License v3.0 | 5 votes |
/** * Exceptions non gérées */ @ExceptionHandler(Exception.class) public ResponseEntity handleUnexpectedException(Exception exception, WebRequest request) { beforeHandling(exception); String path = request.getDescription(false); logger.error("Unexpected error (path=" + path + "):"); logger.error(exception); Map<String, Object> jsonData = new HashMap<>(); jsonData.put("message", StringUtils.isNotEmpty(exception.getMessage()) ? exception.getMessage() : exception.toString()); jsonData.put("status", "500"); jsonData.put("error", "Internal Server Error"); jsonData.put("path", path); jsonData.put("stacktrace", ExceptionUtils.getStackTrace(exception)); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(jsonData); }
Example 2
Source File: GlobalExceptionHandler.java From spring-boot-rest-api-tutorial with Apache License 2.0 | 5 votes |
/** * Resource not found exception response entity. * * @param ex the ex * @param request the request * @return the response entity */ @ExceptionHandler(ResourceNotFoundException.class) public ResponseEntity<?> resourceNotFoundException( ResourceNotFoundException ex, WebRequest request) { ErrorResponse errorDetails = new ErrorResponse(new Date(), HttpStatus.NOT_FOUND.toString(), ex.getMessage(), request.getDescription(false)); return new ResponseEntity<>(errorDetails, HttpStatus.NOT_FOUND); }
Example 3
Source File: TaskanaErrorData.java From taskana with Apache License 2.0 | 5 votes |
TaskanaErrorData(HttpStatus stat, Exception ex, WebRequest req) { this.timestamp = new Date(); this.status = stat.value(); this.error = stat.name(); this.exception = ex.getClass().getName(); this.message = ex.getMessage(); this.path = req.getDescription(false); if (this.path.startsWith("uri=")) { this.path = this.path.substring(4); } }
Example 4
Source File: CustomizedResponseEntityExceptionHandler.java From Library with MIT License | 4 votes |
@ExceptionHandler(NoSuchBookLoanException.class) public final ResponseEntity<ErrorDetail> handleNoSuchBookLoanException(NoSuchBookLoanException ex, WebRequest request) { ErrorDetail errorDetails = new ErrorDetail(new Date(), ex.getMessage(), request.getDescription(false)); return new ResponseEntity<>(errorDetails, HttpStatus.FORBIDDEN); }
Example 5
Source File: GlobalExceptionAdvice.java From spring-boot-rest-api-helpers with MIT License | 4 votes |
@ExceptionHandler(NotFoundException.class) public final ResponseEntity<ErrorDetails> notFoundHandler(Exception ex, WebRequest request) { ErrorDetails errorDetails = new ErrorDetails(new Date(), ex.getMessage(), request.getDescription(false)); return new ResponseEntity<>(errorDetails, HttpStatus.NOT_FOUND); }
Example 6
Source File: GlobalExceptionAdvice.java From spring-boot-rest-api-helpers with MIT License | 4 votes |
@ExceptionHandler(IllegalArgumentException.class) public final ResponseEntity<ErrorDetails> illegalArgumentHanlder(Exception ex, WebRequest request) { ErrorDetails errorDetails = new ErrorDetails(new Date(), ex.getMessage(), request.getDescription(false)); return new ResponseEntity<>(errorDetails, HttpStatus.BAD_REQUEST); }
Example 7
Source File: GlobalExceptionAdvice.java From spring-boot-rest-api-helpers with MIT License | 4 votes |
@ExceptionHandler(BadCredentialsException.class) public final ResponseEntity<ErrorDetails> badCredentialsHandler(Exception ex, WebRequest request) { ErrorDetails errorDetails = new ErrorDetails(new Date(), ex.getMessage(), request.getDescription(false)); return new ResponseEntity<>(errorDetails, HttpStatus.UNAUTHORIZED); }
Example 8
Source File: CustomizedResponseEntityExceptionHandler.java From spring-microservices with MIT License | 4 votes |
@ExceptionHandler(UserNotFoundException.class) public final ResponseEntity<Object> handleUserNotFoundException(UserNotFoundException ex, WebRequest request) { ExceptionResponse exceptionResponse = new ExceptionResponse(new Date(), ex.getMessage(), request.getDescription(false)); return new ResponseEntity(exceptionResponse, HttpStatus.NOT_FOUND); }
Example 9
Source File: CustomizedResponseEntityExceptionHandler.java From spring-microservices with MIT License | 4 votes |
@ExceptionHandler(Exception.class) public final ResponseEntity<Object> handleAllExceptions(Exception ex, WebRequest request) { ExceptionResponse exceptionResponse = new ExceptionResponse(new Date(), ex.getMessage(), request.getDescription(false)); return new ResponseEntity(exceptionResponse, HttpStatus.INTERNAL_SERVER_ERROR); }
Example 10
Source File: CustomizedResponseEntityExceptionHandler.java From spring-web-services with MIT License | 4 votes |
@ExceptionHandler(UserNotFoundException.class) public final ResponseEntity<Object> handleUserNotFoundException(UserNotFoundException ex, WebRequest request) { ExceptionResponse exceptionResponse = new ExceptionResponse(new Date(), ex.getMessage(), request.getDescription(false)); return new ResponseEntity(exceptionResponse, HttpStatus.NOT_FOUND); }
Example 11
Source File: CustomizedResponseEntityExceptionHandler.java From spring-web-services with MIT License | 4 votes |
@ExceptionHandler(Exception.class) public final ResponseEntity<Object> handleAllExceptions(Exception ex, WebRequest request) { ExceptionResponse exceptionResponse = new ExceptionResponse(new Date(), ex.getMessage(), request.getDescription(false)); return new ResponseEntity(exceptionResponse, HttpStatus.INTERNAL_SERVER_ERROR); }
Example 12
Source File: CustomizedResponseEntityExceptionHandler.java From Spring with Apache License 2.0 | 4 votes |
@ExceptionHandler(Exception.class) public ResponseEntity<Object> handleAllExceptions(Exception exception, WebRequest webRequest) { final ExceptionResponse exceptionResponse = new ExceptionResponse(new Date(), exception.getMessage(), webRequest.getDescription(true)); return new ResponseEntity<>(exceptionResponse, HttpStatus.INTERNAL_SERVER_ERROR); }
Example 13
Source File: CustomizedResponseEntityExceptionHandler.java From Library with MIT License | 4 votes |
@ExceptionHandler(BookNotAvailableException.class) public final ResponseEntity<ErrorDetail> handleBookNotAvailableException(BookNotAvailableException ex, WebRequest request) { ErrorDetail errorDetails = new ErrorDetail(new Date(), ex.getMessage(), request.getDescription(false)); return new ResponseEntity<>(errorDetails, HttpStatus.FORBIDDEN); }
Example 14
Source File: CustomizedResponseEntityExceptionHandler.java From Library with MIT License | 4 votes |
@ExceptionHandler(BorrowerThresholdException.class) public final ResponseEntity<ErrorDetail> handleBorrowerThresholdException(BorrowerThresholdException ex, WebRequest request) { ErrorDetail errorDetails = new ErrorDetail(new Date(), ex.getMessage(), request.getDescription(false)); return new ResponseEntity<>(errorDetails, HttpStatus.FORBIDDEN); }
Example 15
Source File: CustomizedResponseEntityExceptionHandler.java From Library with MIT License | 4 votes |
@ExceptionHandler(NoSuchBorrowerException.class) public final ResponseEntity<ErrorDetail> handleNoSuchBorrowerException(NoSuchBorrowerException ex, WebRequest request) { ErrorDetail errorDetails = new ErrorDetail(new Date(), ex.getMessage(), request.getDescription(false)); return new ResponseEntity<>(errorDetails, HttpStatus.FORBIDDEN); }
Example 16
Source File: CustomizedResponseEntityExceptionHandler.java From Library with MIT License | 4 votes |
@ExceptionHandler(BorrowerExistsException.class) public final ResponseEntity<ErrorDetail> handleBorrowerExistsException(BorrowerExistsException ex, WebRequest request) { ErrorDetail errorDetails = new ErrorDetail(new Date(), ex.getMessage(), request.getDescription(false)); return new ResponseEntity<>(errorDetails, HttpStatus.FORBIDDEN); }
Example 17
Source File: CustomizedResponseEntityExceptionHandler.java From in28minutes-spring-microservices with MIT License | 4 votes |
@ExceptionHandler(UserNotFoundException.class) public final ResponseEntity<Object> handleUserNotFoundException(UserNotFoundException ex, WebRequest request) { ExceptionResponse exceptionResponse = new ExceptionResponse(new Date(), ex.getMessage(), request.getDescription(false)); return new ResponseEntity(exceptionResponse, HttpStatus.NOT_FOUND); }
Example 18
Source File: CustomizedResponseEntityExceptionHandler.java From in28minutes-spring-microservices with MIT License | 4 votes |
@ExceptionHandler(Exception.class) public final ResponseEntity<Object> handleAllExceptions(Exception ex, WebRequest request) { ExceptionResponse exceptionResponse = new ExceptionResponse(new Date(), ex.getMessage(), request.getDescription(false)); return new ResponseEntity(exceptionResponse, HttpStatus.INTERNAL_SERVER_ERROR); }
Example 19
Source File: CustomizedResponseEntityExceptionHandler.java From Spring with Apache License 2.0 | 4 votes |
@ExceptionHandler(UserNotFoundException.class) public ResponseEntity<Object> handleUserNotFoundException(UserNotFoundException exception, WebRequest webRequest) { final ExceptionResponse exceptionResponse = new ExceptionResponse(new Date(), exception.getMessage(), webRequest.getDescription(true)); return new ResponseEntity<>(exceptionResponse, HttpStatus.NOT_FOUND); }
Example 20
Source File: GlobalExceptionHandler.java From spring-boot-rest-api-tutorial with Apache License 2.0 | 3 votes |
/** * Globle excpetion handler response entity. * * @param ex the ex * @param request the request * @return the response entity */ @ExceptionHandler(Exception.class) public ResponseEntity<?> globleExcpetionHandler(Exception ex, WebRequest request) { ErrorResponse errorDetails = new ErrorResponse(new Date(), HttpStatus.INTERNAL_SERVER_ERROR.toString() ,ex.getMessage(), request.getDescription(false)); return new ResponseEntity<>(errorDetails, HttpStatus.INTERNAL_SERVER_ERROR); }