Skip to content

Global Exception Catching System

As a backend developer. I want the application to be able to catch and handle all unhandled exceptions, the so that I can log these exceptions and provide a friendly error response to the user, while maintaining the stability and reliability of the system.

  • Exception Catching: The system should be able to catch all unhandled exceptions thrown by the Spring Boot application.
  • Logging: All captured exceptions should be automatically logged to a log file, including the exception type, message and stack trace.
  • Uniform Response Format: For all API responses, the system should return a uniformly formatted error message that includes an HTTP status code, an error code, and a user-friendly description of the error.
  • Error Handling: The system should be able to differentiate between different types of exceptions and provide corresponding handling strategies, e.g., return a 400 status code for user input errors and a 500 status code for server errors.
Edited by Yu Xia