Class ExceptionTranslator

  • All Implemented Interfaces:
    org.zalando.problem.spring.common.AdviceTrait, org.zalando.problem.spring.web.advice.AdviceTrait, org.zalando.problem.spring.web.advice.general.GeneralAdviceTrait, org.zalando.problem.spring.web.advice.general.ProblemAdviceTrait, org.zalando.problem.spring.web.advice.general.ResponseStatusAdviceTrait, org.zalando.problem.spring.web.advice.general.ThrowableAdviceTrait, org.zalando.problem.spring.web.advice.general.UnsupportedOperationAdviceTrait, org.zalando.problem.spring.web.advice.http.HttpAdviceTrait, org.zalando.problem.spring.web.advice.http.MethodNotAllowedAdviceTrait, org.zalando.problem.spring.web.advice.http.NotAcceptableAdviceTrait, org.zalando.problem.spring.web.advice.http.UnsupportedMediaTypeAdviceTrait, org.zalando.problem.spring.web.advice.io.IOAdviceTrait, org.zalando.problem.spring.web.advice.io.MessageNotReadableAdviceTrait, org.zalando.problem.spring.web.advice.io.MultipartAdviceTrait, org.zalando.problem.spring.web.advice.io.TypeMismatchAdviceTrait, org.zalando.problem.spring.web.advice.network.NetworkAdviceTrait, org.zalando.problem.spring.web.advice.network.SocketTimeoutAdviceTrait, org.zalando.problem.spring.web.advice.ProblemHandling, org.zalando.problem.spring.web.advice.routing.MissingServletRequestParameterAdviceTrait, org.zalando.problem.spring.web.advice.routing.MissingServletRequestPartAdviceTrait, org.zalando.problem.spring.web.advice.routing.NoHandlerFoundAdviceTrait, org.zalando.problem.spring.web.advice.routing.RoutingAdviceTrait, org.zalando.problem.spring.web.advice.routing.ServletRequestBindingAdviceTrait, org.zalando.problem.spring.web.advice.validation.BaseBindingResultAdviceTrait, org.zalando.problem.spring.web.advice.validation.BindAdviceTrait, org.zalando.problem.spring.web.advice.validation.ConstraintViolationAdviceTrait, org.zalando.problem.spring.web.advice.validation.MethodArgumentNotValidAdviceTrait, org.zalando.problem.spring.web.advice.validation.ValidationAdviceTrait

    @ControllerAdvice
    public class ExceptionTranslator
    extends Object
    implements org.zalando.problem.spring.web.advice.ProblemHandling
    Controller advice to translate the server side exceptions to client-friendly json structures. The error response follows RFC7807 - Problem Details for HTTP APIs (https://tools.ietf.org/html/rfc7807)
    • Method Summary

      All Methods Instance Methods Concrete Methods Default Methods 
      Modifier and Type Method Description
      default org.zalando.problem.StatusType defaultConstraintViolationStatus()  
      default URI defaultConstraintViolationType()  
      default String formatFieldName​(String arg0)  
      org.springframework.http.ResponseEntity<org.zalando.problem.Problem> handleBadRequestAlertException​(BadRequestAlertException ex, org.springframework.web.context.request.NativeWebRequest request)  
      org.springframework.http.ResponseEntity<org.zalando.problem.Problem> handleConcurrencyFailure​(org.springframework.dao.ConcurrencyFailureException ex, org.springframework.web.context.request.NativeWebRequest request)  
      org.springframework.http.ResponseEntity<org.zalando.problem.Problem> handleMethodArgumentNotValid​(org.springframework.web.bind.MethodArgumentNotValidException ex, org.springframework.web.context.request.NativeWebRequest request)  
      org.springframework.http.ResponseEntity<org.zalando.problem.Problem> handleNoSuchElementException​(NoSuchElementException ex, org.springframework.web.context.request.NativeWebRequest request)  
      default org.springframework.http.ResponseEntity<org.zalando.problem.Problem> newConstraintViolationProblem​(Throwable arg0, Collection<org.zalando.problem.violations.Violation> arg1, org.springframework.web.context.request.NativeWebRequest arg2)  
      org.springframework.http.ResponseEntity<org.zalando.problem.Problem> process​(org.springframework.http.ResponseEntity<org.zalando.problem.Problem> entity, org.springframework.web.context.request.NativeWebRequest request)
      Post-process the Problem payload to add the message key for the front-end if needed
      • Methods inherited from interface org.zalando.problem.spring.common.AdviceTrait

        createStackTrace, isCausalChainsEnabled, prepare, process, resolveResponseStatus, toProblem, toProblem, toProblem
      • Methods inherited from interface org.zalando.problem.spring.web.advice.AdviceTrait

        create, create, create, create, create, create, create, create, create, fallback, log, negotiate
      • Methods inherited from interface org.zalando.problem.spring.web.advice.validation.BaseBindingResultAdviceTrait

        createViolation, createViolation, createViolations
      • Methods inherited from interface org.zalando.problem.spring.web.advice.validation.BindAdviceTrait

        handleBindingResult
      • Methods inherited from interface org.zalando.problem.spring.web.advice.validation.ConstraintViolationAdviceTrait

        createViolation, handleConstraintViolation
      • Methods inherited from interface org.zalando.problem.spring.web.advice.io.MessageNotReadableAdviceTrait

        handleMessageNotReadableException
      • Methods inherited from interface org.zalando.problem.spring.web.advice.http.MethodNotAllowedAdviceTrait

        handleRequestMethodNotSupportedException
      • Methods inherited from interface org.zalando.problem.spring.web.advice.routing.MissingServletRequestParameterAdviceTrait

        handleMissingServletRequestParameter
      • Methods inherited from interface org.zalando.problem.spring.web.advice.routing.MissingServletRequestPartAdviceTrait

        handleMissingServletRequestPart
      • Methods inherited from interface org.zalando.problem.spring.web.advice.io.MultipartAdviceTrait

        handleMultipart
      • Methods inherited from interface org.zalando.problem.spring.web.advice.routing.NoHandlerFoundAdviceTrait

        handleNoHandlerFound
      • Methods inherited from interface org.zalando.problem.spring.web.advice.http.NotAcceptableAdviceTrait

        handleMediaTypeNotAcceptable
      • Methods inherited from interface org.zalando.problem.spring.web.advice.general.ProblemAdviceTrait

        handleProblem
      • Methods inherited from interface org.zalando.problem.spring.web.advice.general.ResponseStatusAdviceTrait

        handleResponseStatusException
      • Methods inherited from interface org.zalando.problem.spring.web.advice.routing.ServletRequestBindingAdviceTrait

        handleServletRequestBinding
      • Methods inherited from interface org.zalando.problem.spring.web.advice.network.SocketTimeoutAdviceTrait

        handleSocketTimeout
      • Methods inherited from interface org.zalando.problem.spring.web.advice.general.ThrowableAdviceTrait

        handleThrowable
      • Methods inherited from interface org.zalando.problem.spring.web.advice.io.TypeMismatchAdviceTrait

        handleTypeMismatch
      • Methods inherited from interface org.zalando.problem.spring.web.advice.http.UnsupportedMediaTypeAdviceTrait

        handleMediaTypeNotSupportedException
      • Methods inherited from interface org.zalando.problem.spring.web.advice.general.UnsupportedOperationAdviceTrait

        handleUnsupportedOperation
    • Constructor Detail

      • ExceptionTranslator

        public ExceptionTranslator()
    • Method Detail

      • process

        public org.springframework.http.ResponseEntity<org.zalando.problem.Problem> process​(@Nullable
                                                                                            org.springframework.http.ResponseEntity<org.zalando.problem.Problem> entity,
                                                                                            org.springframework.web.context.request.NativeWebRequest request)
        Post-process the Problem payload to add the message key for the front-end if needed
        Specified by:
        process in interface org.zalando.problem.spring.web.advice.AdviceTrait
      • handleMethodArgumentNotValid

        public org.springframework.http.ResponseEntity<org.zalando.problem.Problem> handleMethodArgumentNotValid​(org.springframework.web.bind.MethodArgumentNotValidException ex,
                                                                                                                 @Nonnull
                                                                                                                 org.springframework.web.context.request.NativeWebRequest request)
        Specified by:
        handleMethodArgumentNotValid in interface org.zalando.problem.spring.web.advice.validation.MethodArgumentNotValidAdviceTrait
      • handleNoSuchElementException

        @ExceptionHandler
        public org.springframework.http.ResponseEntity<org.zalando.problem.Problem> handleNoSuchElementException​(NoSuchElementException ex,
                                                                                                                 org.springframework.web.context.request.NativeWebRequest request)
      • handleBadRequestAlertException

        @ExceptionHandler
        public org.springframework.http.ResponseEntity<org.zalando.problem.Problem> handleBadRequestAlertException​(BadRequestAlertException ex,
                                                                                                                   org.springframework.web.context.request.NativeWebRequest request)
      • handleConcurrencyFailure

        @ExceptionHandler
        public org.springframework.http.ResponseEntity<org.zalando.problem.Problem> handleConcurrencyFailure​(org.springframework.dao.ConcurrencyFailureException ex,
                                                                                                             org.springframework.web.context.request.NativeWebRequest request)
      • defaultConstraintViolationType

        public default URI defaultConstraintViolationType()
      • defaultConstraintViolationStatus

        public default org.zalando.problem.StatusType defaultConstraintViolationStatus()
      • formatFieldName

        public default String formatFieldName​(String arg0)
      • newConstraintViolationProblem

        public default org.springframework.http.ResponseEntity<org.zalando.problem.Problem> newConstraintViolationProblem​(Throwable arg0,
                                                                                                                          Collection<org.zalando.problem.violations.Violation> arg1,
                                                                                                                          org.springframework.web.context.request.NativeWebRequest arg2)