yookue / exception-handler-spring-boot-starter

Exception handler for spring boot starter

Home Page:https://mvnrepository.com/artifact/com.yookue.springstarter/exception-handler-spring-boot-starter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exception Handler Spring Boot Starter

Spring Boot application enables a global exception handler, to handle exceptions gracefully. Supports handling exceptions occurred in filters, controllers, and event listeners.

Quickstart

  • Import dependencies
    <dependency>
        <groupId>com.yookue.springstarter</groupId>
        <artifactId>exception-handler-spring-boot-starter</artifactId>
        <version>LATEST</version>
    </dependency>

By default, this starter will auto take effect, you can turn it off by spring.exception-handler.enabled = false

  • Configure Spring Boot application.yml with prefix spring.exception-handler (Optional)
spring:
    exception-handler:
        exception-filter:
            filter-paths:
                - '/**'
            exclude-paths:
                - '/foo/**'
                - '/bar/**'
        exception-resolver:
            invokable-interceptors:
                - com.foo.bar
  • This starter supports the most popular template engines, including:

    • Thymeleaf
    • FreeMarker
    • Groovy
    • Mustache
    • JSP
  • Optional feature: If you're using a template engine in your application, you may activate a simple error controller by @EnableSimpleErrorController annotation, which extends from BasicErrorController and handles both HTML requests and REST requests.

You can also customize the error data generated by this error controller, by the way of defining a bean which implements the ErrorControllerCustomizer facade.

You can handle the event named ServletExceptionHandledEvent to process your own logic, such as logging and so on.

Document

Requirement

  • jdk 17+

License

This project is under the Apache License 2.0

See the NOTICE.txt file for required notices and attributions.

Donation

You like this package? Then donate to Yookue to support the development.

Website

About

Exception handler for spring boot starter

https://mvnrepository.com/artifact/com.yookue.springstarter/exception-handler-spring-boot-starter

License:Apache License 2.0


Languages

Language:Java 99.2%Language:HTML 0.3%Language:Smarty 0.3%Language:Mustache 0.2%