Class GlobalExceptionHandler

java.lang.Object
swiss.trustbroker.exception.GlobalExceptionHandler

@ControllerAdvice public class GlobalExceptionHandler extends Object
Spring MVC exception handler towards REST and WEB clients. Exception stacks are not shown, except when DEBUG is enabled. This is needed because most of the exceptions below are either thrown when data from the network is unexpected (in this case we can track back to code without the exception stack, because the error message is speaking enough) or because under load we have threading problems in which case the exception stack is more than needed and if caught and discarded in code within is lost otherwise.
  • Constructor Details

  • Method Details

    • handleDeniedException

      @ExceptionHandler(swiss.trustbroker.common.exception.RequestDeniedException.class) public org.springframework.http.ResponseEntity<String> handleDeniedException(swiss.trustbroker.common.exception.RequestDeniedException ex)
    • handleTechnicalException

      @ExceptionHandler(swiss.trustbroker.common.exception.TechnicalException.class) public org.springframework.http.ResponseEntity<String> handleTechnicalException(swiss.trustbroker.common.exception.TechnicalException ex)
    • handleAnyException

      public void handleAnyException(Exception ex, jakarta.servlet.http.HttpServletResponse response)
    • logException

      public int logException(Throwable ex)
    • logException

      public static int logException(Throwable ex, NetworkConfig networkConfig)
    • getMessageOfExceptionOrCause

      public static String getMessageOfExceptionOrCause(Exception ex, boolean useToStringForCause)
      Parameters:
      ex -
      Returns:
      message of the exception or of the root cause if the exception has a null message