Java Code Examples for org.springframework.web.bind.MissingServletRequestParameterException#getParameterName()
The following examples show how to use
org.springframework.web.bind.MissingServletRequestParameterException#getParameterName() .
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: GlobalControllerAdvice.java From springdoc-openapi with Apache License 2.0 | 5 votes |
@ExceptionHandler(MissingServletRequestParameterException.class) @ResponseStatus(code = HttpStatus.BAD_REQUEST) public ResponseEntity<ErrorMessage> handleMissingServletRequestParameterException(MissingServletRequestParameterException ex ) { List<String> errors = new ArrayList<>(); String error = ex.getParameterName() + ", " + ex.getMessage(); errors.add(error); ErrorMessage errorMessage = new ErrorMessage(errors); return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); }
Example 2
Source File: GlobalControllerAdvice.java From springdoc-openapi with Apache License 2.0 | 5 votes |
@ExceptionHandler(MissingServletRequestParameterException.class) @ResponseStatus(code = HttpStatus.BAD_REQUEST) public ResponseEntity<ErrorMessage> handleMissingServletRequestParameterException(MissingServletRequestParameterException ex ) { List<String> errors = new ArrayList<>(); String error = ex.getParameterName() + ", " + ex.getMessage(); errors.add(error); ErrorMessage errorMessage = new ErrorMessage(errors); return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); }
Example 3
Source File: GlobalControllerAdvice.java From springdoc-openapi with Apache License 2.0 | 5 votes |
@ExceptionHandler(MissingServletRequestParameterException.class) @ResponseStatus(code = HttpStatus.BAD_REQUEST) public ResponseEntity<ErrorMessage> handleMissingServletRequestParameterException(MissingServletRequestParameterException ex ) { List<String> errors = new ArrayList<>(); String error = ex.getParameterName() + ", " + ex.getMessage(); errors.add(error); ErrorMessage errorMessage = new ErrorMessage(errors); return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); }
Example 4
Source File: CustomRestExceptionHandler.java From xxproject with Apache License 2.0 | 5 votes |
@Override protected ResponseEntity<Object> handleMissingServletRequestParameter(final MissingServletRequestParameterException ex, final HttpHeaders headers, final HttpStatus status, final WebRequest request) { logger.info(ex.getClass().getName()); // final String error = ex.getParameterName() + " parameter is missing"; final ApiError apiError = new ApiError(HttpStatus.BAD_REQUEST, ex.getLocalizedMessage(), error); return new ResponseEntity<Object>(apiError, new HttpHeaders(), apiError.getStatus()); }
Example 5
Source File: RestExceptionHandler.java From POC with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} * * Handle MissingServletRequestParameterException. Triggered when a 'required' request * parameter is missing. */ @Override protected ResponseEntity<Object> handleMissingServletRequestParameter(MissingServletRequestParameterException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { final String error = ex.getParameterName() + " parameter is missing"; return buildResponseEntity(new ApiError(status, error, ex)); }
Example 6
Source File: CustomRestExceptionHandler.java From tutorials with MIT License | 5 votes |
@Override protected ResponseEntity<Object> handleMissingServletRequestParameter(final MissingServletRequestParameterException ex, final HttpHeaders headers, final HttpStatus status, final WebRequest request) { logger.info(ex.getClass().getName()); // final String error = ex.getParameterName() + " parameter is missing"; final ApiError apiError = new ApiError(HttpStatus.BAD_REQUEST, ex.getLocalizedMessage(), error); return new ResponseEntity<Object>(apiError, new HttpHeaders(), apiError.getStatus()); }
Example 7
Source File: ExceptionProcessor.java From personal_book_library_web_project with MIT License | 4 votes |
@ExceptionHandler(MissingServletRequestParameterException.class) @ResponseStatus(value = HttpStatus.NOT_FOUND) @ResponseBody public ServiceExceptionDetails processMissingServletRequestParameterException(HttpServletRequest httpServletRequest, MissingServletRequestParameterException exception) { String missingParameterName = exception.getParameterName(); String missingParameterType = exception.getParameterType(); String errorMessage = "Missing parameter: [name: " + missingParameterName + ", type: " + missingParameterType + "]"; String detailedErrorMessage = exception.getMessage(); String errorURL = httpServletRequest.getRequestURL().toString(); return new ServiceExceptionDetails(errorMessage, detailedErrorMessage, errorURL); }
Example 8
Source File: RestResponseEntityExceptionHandler.java From cerberus-source with GNU General Public License v3.0 | 4 votes |
@Override protected ResponseEntity<Object> handleMissingServletRequestParameter(final MissingServletRequestParameterException ex, final HttpHeaders headers, final HttpStatus status, final WebRequest request) { String name = ex.getParameterName(); final String bodyOfResponse = name + " parameter is missing"; return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.EXPECTATION_FAILED, request); }
Example 9
Source File: RestExceptionHandler.java From spring-boot-akka-event-sourcing-starter with Apache License 2.0 | 3 votes |
/** * Handle MissingServletRequestParameterException. Triggered when a 'required' request parameter is missing. * * @param ex MissingServletRequestParameterException * @param headers HttpHeaders * @param status HttpStatus * @param request WebRequest * @return the ApiError object */ @Override protected ResponseEntity<Object> handleMissingServletRequestParameter( MissingServletRequestParameterException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { String error = ex.getParameterName() + " parameter is missing"; return buildResponseEntity(new ApiError(BAD_REQUEST, error, ex)); }
Example 10
Source File: RestExceptionHandler.java From spring-glee-o-meter with GNU General Public License v3.0 | 3 votes |
/** * Handle MissingServletRequestParameterException. Triggered when a 'required' request parameter is missing. * * @param ex MissingServletRequestParameterException * @param headers HttpHeaders * @param status HttpStatus * @param request WebRequest * @return the ApiError object */ @Override protected ResponseEntity<Object> handleMissingServletRequestParameter( MissingServletRequestParameterException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { String error = ex.getParameterName() + " parameter is missing"; return buildResponseEntity(new ApiError(BAD_REQUEST, error, ex)); }
Example 11
Source File: RestExceptionHandler.java From spring-boot-exception-handling with MIT License | 3 votes |
/** * Handle MissingServletRequestParameterException. Triggered when a 'required' request parameter is missing. * * @param ex MissingServletRequestParameterException * @param headers HttpHeaders * @param status HttpStatus * @param request WebRequest * @return the ApiError object */ @Override protected ResponseEntity<Object> handleMissingServletRequestParameter( MissingServletRequestParameterException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { String error = ex.getParameterName() + " parameter is missing"; return buildResponseEntity(new ApiError(BAD_REQUEST, error, ex)); }
Example 12
Source File: RestExceptionHandler.java From spring-boot with Apache License 2.0 | 2 votes |
/** * Handle MissingServletRequestParameterException. Triggered when a 'required' request parameter is missing. * * @param ex MissingServletRequestParameterException * @param headers HttpHeaders * @param status HttpStatus * @param request WebRequest * @return the ApiError object */ @Override protected ResponseEntity<Object> handleMissingServletRequestParameter(MissingServletRequestParameterException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { String error = ex.getParameterName() + " parameter is missing"; return buildResponseEntity(new RestApiError(BAD_REQUEST, error, ex)); }