Class NtsExceptionTranslator

  • All Implemented Interfaces:
    org.zalando.problem.spring.common.AdviceTrait, org.zalando.problem.spring.webflux.advice.AdviceTrait, org.zalando.problem.spring.webflux.advice.general.GeneralAdviceTrait, org.zalando.problem.spring.webflux.advice.general.ProblemAdviceTrait, org.zalando.problem.spring.webflux.advice.general.ThrowableAdviceTrait, org.zalando.problem.spring.webflux.advice.general.UnsupportedOperationAdviceTrait, org.zalando.problem.spring.webflux.advice.http.HttpAdviceTrait, org.zalando.problem.spring.webflux.advice.http.MethodNotAllowedAdviceTrait, org.zalando.problem.spring.webflux.advice.http.NotAcceptableAdviceTrait, org.zalando.problem.spring.webflux.advice.http.ResponseStatusAdviceTrait, org.zalando.problem.spring.webflux.advice.http.UnsupportedMediaTypeAdviceTrait, org.zalando.problem.spring.webflux.advice.network.NetworkAdviceTrait, org.zalando.problem.spring.webflux.advice.network.SocketTimeoutAdviceTrait, org.zalando.problem.spring.webflux.advice.ProblemHandling, org.zalando.problem.spring.webflux.advice.security.AccessDeniedAdviceTrait, org.zalando.problem.spring.webflux.advice.security.AuthenticationAdviceTrait, org.zalando.problem.spring.webflux.advice.security.SecurityAdviceTrait, org.zalando.problem.spring.webflux.advice.SpringAdviceTrait, org.zalando.problem.spring.webflux.advice.validation.BaseBindingResultAdviceTrait, org.zalando.problem.spring.webflux.advice.validation.BindAdviceTrait, org.zalando.problem.spring.webflux.advice.validation.ConstraintViolationAdviceTrait, org.zalando.problem.spring.webflux.advice.validation.ValidationAdviceTrait

    @ControllerAdvice
    @ConditionalOnMissingBean(name="exceptionTranslator")
    public class NtsExceptionTranslator
    extends Object
    implements org.zalando.problem.spring.webflux.advice.ProblemHandling, org.zalando.problem.spring.webflux.advice.security.SecurityAdviceTrait
    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).
    • Constructor Summary

      Constructors 
      Constructor Description
      NtsExceptionTranslator​(org.springframework.core.env.Environment env)  
    • 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)  
      reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<org.zalando.problem.Problem>> handleBadRequestAlertException​(BadRequestAlertException ex, org.springframework.web.server.ServerWebExchange request)  
      reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<org.zalando.problem.Problem>> handleBindingResult​(org.springframework.web.bind.support.WebExchangeBindException ex, org.springframework.web.server.ServerWebExchange request)  
      reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<org.zalando.problem.Problem>> handleConcurrencyFailure​(org.springframework.dao.ConcurrencyFailureException ex, org.springframework.web.server.ServerWebExchange request)  
      reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<org.zalando.problem.Problem>> handleFormValidateException​(FormValidateException ex, org.springframework.web.server.ServerWebExchange request)  
      reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<org.zalando.problem.Problem>> handleNotFoundException​(NotFoundException ex, org.springframework.web.server.ServerWebExchange request)  
      default reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<org.zalando.problem.Problem>> newConstraintViolationProblem​(Throwable arg0, Collection<org.zalando.problem.violations.Violation> arg1, org.springframework.web.server.ServerWebExchange arg2)  
      org.zalando.problem.ProblemBuilder prepare​(Throwable throwable, org.zalando.problem.StatusType status, URI type)  
      reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<org.zalando.problem.Problem>> process​(org.springframework.http.ResponseEntity<org.zalando.problem.Problem> entity, org.springframework.web.server.ServerWebExchange 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.webflux.advice.security.AccessDeniedAdviceTrait

        handleAccessDenied
      • Methods inherited from interface org.zalando.problem.spring.common.AdviceTrait

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

        create, create, create, create, create, create, create, create, create, fallback, log, negotiate
      • Methods inherited from interface org.zalando.problem.spring.webflux.advice.security.AuthenticationAdviceTrait

        handleAuthentication
      • Methods inherited from interface org.zalando.problem.spring.webflux.advice.validation.BaseBindingResultAdviceTrait

        createViolation, createViolation, createViolations
      • Methods inherited from interface org.zalando.problem.spring.webflux.advice.validation.ConstraintViolationAdviceTrait

        createViolation, handleConstraintViolation
      • Methods inherited from interface org.zalando.problem.spring.webflux.advice.http.MethodNotAllowedAdviceTrait

        handleRequestMethodNotSupportedException
      • Methods inherited from interface org.zalando.problem.spring.webflux.advice.http.NotAcceptableAdviceTrait

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

        handleProblem
      • Methods inherited from interface org.zalando.problem.spring.webflux.advice.http.ResponseStatusAdviceTrait

        handleResponseStatusException
      • Methods inherited from interface org.zalando.problem.spring.webflux.advice.network.SocketTimeoutAdviceTrait

        handleSocketTimeout
      • Methods inherited from interface org.zalando.problem.spring.webflux.advice.SpringAdviceTrait

        create, create, toProblem, toStatus
      • Methods inherited from interface org.zalando.problem.spring.webflux.advice.general.ThrowableAdviceTrait

        handleThrowable
      • Methods inherited from interface org.zalando.problem.spring.webflux.advice.http.UnsupportedMediaTypeAdviceTrait

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

        handleUnsupportedOperation
    • Constructor Detail

      • NtsExceptionTranslator

        public NtsExceptionTranslator​(org.springframework.core.env.Environment env)
    • Method Detail

      • process

        public reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<org.zalando.problem.Problem>> process​(@Nullable
                                                                                                                         org.springframework.http.ResponseEntity<org.zalando.problem.Problem> entity,
                                                                                                                         org.springframework.web.server.ServerWebExchange 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.webflux.advice.AdviceTrait
      • handleBindingResult

        public reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<org.zalando.problem.Problem>> handleBindingResult​(org.springframework.web.bind.support.WebExchangeBindException ex,
                                                                                                                                     @Nonnull
                                                                                                                                     org.springframework.web.server.ServerWebExchange request)
        Specified by:
        handleBindingResult in interface org.zalando.problem.spring.webflux.advice.validation.BindAdviceTrait
      • handleBadRequestAlertException

        @ExceptionHandler
        public reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<org.zalando.problem.Problem>> handleBadRequestAlertException​(BadRequestAlertException ex,
                                                                                                                                                org.springframework.web.server.ServerWebExchange request)
      • handleConcurrencyFailure

        @ExceptionHandler
        public reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<org.zalando.problem.Problem>> handleConcurrencyFailure​(org.springframework.dao.ConcurrencyFailureException ex,
                                                                                                                                          org.springframework.web.server.ServerWebExchange request)
      • prepare

        public org.zalando.problem.ProblemBuilder prepare​(Throwable throwable,
                                                          org.zalando.problem.StatusType status,
                                                          URI type)
        Specified by:
        prepare in interface org.zalando.problem.spring.common.AdviceTrait
      • handleFormValidateException

        @ExceptionHandler
        public reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<org.zalando.problem.Problem>> handleFormValidateException​(FormValidateException ex,
                                                                                                                                             org.springframework.web.server.ServerWebExchange request)
      • handleNotFoundException

        @ExceptionHandler
        public reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<org.zalando.problem.Problem>> handleNotFoundException​(NotFoundException ex,
                                                                                                                                         org.springframework.web.server.ServerWebExchange request)
      • defaultConstraintViolationType

        public default URI defaultConstraintViolationType()
      • defaultConstraintViolationStatus

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

        public default String formatFieldName​(String arg0)
      • newConstraintViolationProblem

        public default reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<org.zalando.problem.Problem>> newConstraintViolationProblem​(Throwable arg0,
                                                                                                                                                       Collection<org.zalando.problem.violations.Violation> arg1,
                                                                                                                                                       org.springframework.web.server.ServerWebExchange arg2)