List of usage examples for org.springframework.http HttpStatus NOT_ACCEPTABLE
HttpStatus NOT_ACCEPTABLE
To view the source code for org.springframework.http HttpStatus NOT_ACCEPTABLE.
Click Source Link
From source file:fsl.ta.toms.roms.webservices.RoadCompliancy.java
@ExceptionHandler(Exception.class) public ResponseEntity<Exception> interceptorInvalidFieldException(HttpServletRequest req, Exception e) { System.err.println(e.getMessage()); return new ResponseEntity<Exception>(e, HttpStatus.NOT_ACCEPTABLE); }
From source file:io.spring.initializr.web.project.MainControllerIntegrationTests.java
@Test public void dependencyNotInRange() { try {//from w w w. j av a 2 s . c o m execute("/starter.tgz?style=org.acme:bur", byte[].class, null, (String[]) null); } catch (HttpClientErrorException ex) { assertEquals(HttpStatus.NOT_ACCEPTABLE, ex.getStatusCode()); } }
From source file:io.spring.initializr.web.project.MainControllerIntegrationTests.java
@Test public void metadataWithUnknownAcceptHeader() { try {/*from w w w . jav a 2 s. c o m*/ invokeHome(null, "application/vnd.initializr.v5.4+json"); } catch (HttpClientErrorException ex) { assertEquals(HttpStatus.NOT_ACCEPTABLE, ex.getStatusCode()); } }
From source file:io.spring.initializr.web.project.MainControllerServiceMetadataIntegrationTests.java
@Test public void textPlainNotAccepted() { try {//from www. j av a2 s . co m execute("/metadata/config", String.class, null, "text/plain"); } catch (HttpClientErrorException ex) { assertEquals(HttpStatus.NOT_ACCEPTABLE, ex.getStatusCode()); } }
From source file:org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerSupport.java
/** * Provides handling for standard Spring MVC exceptions. * @param ex the target exception//from w ww . ja v a2s. c om * @param request the current request */ @ExceptionHandler(value = { NoSuchRequestHandlingMethodException.class, HttpRequestMethodNotSupportedException.class, HttpMediaTypeNotSupportedException.class, HttpMediaTypeNotAcceptableException.class, MissingServletRequestParameterException.class, ServletRequestBindingException.class, ConversionNotSupportedException.class, TypeMismatchException.class, HttpMessageNotReadableException.class, HttpMessageNotWritableException.class, MethodArgumentNotValidException.class, MissingServletRequestPartException.class, BindException.class }) public final ResponseEntity<Object> handleException(Exception ex, WebRequest request) { HttpHeaders headers = new HttpHeaders(); HttpStatus status; Object body; if (ex instanceof NoSuchRequestHandlingMethodException) { status = HttpStatus.NOT_FOUND; body = handleNoSuchRequestHandlingMethod((NoSuchRequestHandlingMethodException) ex, headers, status, request); } else if (ex instanceof HttpRequestMethodNotSupportedException) { status = HttpStatus.METHOD_NOT_ALLOWED; body = handleHttpRequestMethodNotSupported((HttpRequestMethodNotSupportedException) ex, headers, status, request); } else if (ex instanceof HttpMediaTypeNotSupportedException) { status = HttpStatus.UNSUPPORTED_MEDIA_TYPE; body = handleHttpMediaTypeNotSupported((HttpMediaTypeNotSupportedException) ex, headers, status, request); } else if (ex instanceof HttpMediaTypeNotAcceptableException) { status = HttpStatus.NOT_ACCEPTABLE; body = handleHttpMediaTypeNotAcceptable((HttpMediaTypeNotAcceptableException) ex, headers, status, request); } else if (ex instanceof MissingServletRequestParameterException) { status = HttpStatus.BAD_REQUEST; body = handleMissingServletRequestParameter((MissingServletRequestParameterException) ex, headers, status, request); } else if (ex instanceof ServletRequestBindingException) { status = HttpStatus.BAD_REQUEST; body = handleServletRequestBindingException((ServletRequestBindingException) ex, headers, status, request); } else if (ex instanceof ConversionNotSupportedException) { status = HttpStatus.INTERNAL_SERVER_ERROR; body = handleConversionNotSupported((ConversionNotSupportedException) ex, headers, status, request); } else if (ex instanceof TypeMismatchException) { status = HttpStatus.BAD_REQUEST; body = handleTypeMismatch((TypeMismatchException) ex, headers, status, request); } else if (ex instanceof HttpMessageNotReadableException) { status = HttpStatus.BAD_REQUEST; body = handleHttpMessageNotReadable((HttpMessageNotReadableException) ex, headers, status, request); } else if (ex instanceof HttpMessageNotWritableException) { status = HttpStatus.INTERNAL_SERVER_ERROR; body = handleHttpMessageNotWritable((HttpMessageNotWritableException) ex, headers, status, request); } else if (ex instanceof MethodArgumentNotValidException) { status = HttpStatus.BAD_REQUEST; body = handleMethodArgumentNotValid((MethodArgumentNotValidException) ex, headers, status, request); } else if (ex instanceof MissingServletRequestPartException) { status = HttpStatus.BAD_REQUEST; body = handleMissingServletRequestPart((MissingServletRequestPartException) ex, headers, status, request); } else if (ex instanceof BindException) { status = HttpStatus.BAD_REQUEST; body = handleBindException((BindException) ex, headers, status, request); } else { logger.warn("Unknown exception type: " + ex.getClass().getName()); status = HttpStatus.INTERNAL_SERVER_ERROR; body = handleExceptionInternal(ex, headers, status, request); } return new ResponseEntity<Object>(body, headers, status); }
From source file:org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler.java
/** * Provides handling for standard Spring MVC exceptions. * @param ex the target exception//from w w w .j a va 2 s . co m * @param request the current request */ @ExceptionHandler({ HttpRequestMethodNotSupportedException.class, HttpMediaTypeNotSupportedException.class, HttpMediaTypeNotAcceptableException.class, MissingPathVariableException.class, MissingServletRequestParameterException.class, ServletRequestBindingException.class, ConversionNotSupportedException.class, TypeMismatchException.class, HttpMessageNotReadableException.class, HttpMessageNotWritableException.class, MethodArgumentNotValidException.class, MissingServletRequestPartException.class, BindException.class, NoHandlerFoundException.class, AsyncRequestTimeoutException.class }) @Nullable public final ResponseEntity<Object> handleException(Exception ex, WebRequest request) { HttpHeaders headers = new HttpHeaders(); if (ex instanceof HttpRequestMethodNotSupportedException) { HttpStatus status = HttpStatus.METHOD_NOT_ALLOWED; return handleHttpRequestMethodNotSupported((HttpRequestMethodNotSupportedException) ex, headers, status, request); } else if (ex instanceof HttpMediaTypeNotSupportedException) { HttpStatus status = HttpStatus.UNSUPPORTED_MEDIA_TYPE; return handleHttpMediaTypeNotSupported((HttpMediaTypeNotSupportedException) ex, headers, status, request); } else if (ex instanceof HttpMediaTypeNotAcceptableException) { HttpStatus status = HttpStatus.NOT_ACCEPTABLE; return handleHttpMediaTypeNotAcceptable((HttpMediaTypeNotAcceptableException) ex, headers, status, request); } else if (ex instanceof MissingPathVariableException) { HttpStatus status = HttpStatus.INTERNAL_SERVER_ERROR; return handleMissingPathVariable((MissingPathVariableException) ex, headers, status, request); } else if (ex instanceof MissingServletRequestParameterException) { HttpStatus status = HttpStatus.BAD_REQUEST; return handleMissingServletRequestParameter((MissingServletRequestParameterException) ex, headers, status, request); } else if (ex instanceof ServletRequestBindingException) { HttpStatus status = HttpStatus.BAD_REQUEST; return handleServletRequestBindingException((ServletRequestBindingException) ex, headers, status, request); } else if (ex instanceof ConversionNotSupportedException) { HttpStatus status = HttpStatus.INTERNAL_SERVER_ERROR; return handleConversionNotSupported((ConversionNotSupportedException) ex, headers, status, request); } else if (ex instanceof TypeMismatchException) { HttpStatus status = HttpStatus.BAD_REQUEST; return handleTypeMismatch((TypeMismatchException) ex, headers, status, request); } else if (ex instanceof HttpMessageNotReadableException) { HttpStatus status = HttpStatus.BAD_REQUEST; return handleHttpMessageNotReadable((HttpMessageNotReadableException) ex, headers, status, request); } else if (ex instanceof HttpMessageNotWritableException) { HttpStatus status = HttpStatus.INTERNAL_SERVER_ERROR; return handleHttpMessageNotWritable((HttpMessageNotWritableException) ex, headers, status, request); } else if (ex instanceof MethodArgumentNotValidException) { HttpStatus status = HttpStatus.BAD_REQUEST; return handleMethodArgumentNotValid((MethodArgumentNotValidException) ex, headers, status, request); } else if (ex instanceof MissingServletRequestPartException) { HttpStatus status = HttpStatus.BAD_REQUEST; return handleMissingServletRequestPart((MissingServletRequestPartException) ex, headers, status, request); } else if (ex instanceof BindException) { HttpStatus status = HttpStatus.BAD_REQUEST; return handleBindException((BindException) ex, headers, status, request); } else if (ex instanceof NoHandlerFoundException) { HttpStatus status = HttpStatus.NOT_FOUND; return handleNoHandlerFoundException((NoHandlerFoundException) ex, headers, status, request); } else if (ex instanceof AsyncRequestTimeoutException) { HttpStatus status = HttpStatus.SERVICE_UNAVAILABLE; return handleAsyncRequestTimeoutException((AsyncRequestTimeoutException) ex, headers, status, request); } else { if (logger.isWarnEnabled()) { logger.warn("Unknown exception type: " + ex.getClass().getName()); } HttpStatus status = HttpStatus.INTERNAL_SERVER_ERROR; return handleExceptionInternal(ex, null, headers, status, request); } }