@@ -22,6 +22,30 @@ can send us a {github-code}[pull request].
2222== Spring Boot application
2323
2424
25+ [[howto-failure-analyzer]]
26+ === Create your own FailureAnalyzer
27+ {dc-spring-boot}/diagnostics/FailureAnalyzer.{dc-ext}[[`FailureAnalyzer`] is a great way
28+ to intercept an exception on startup and turn it into a human-readable message, wrapped
29+ into a {dc-spring-boot}/diagnostics/FailureAnalysis.{dc-ext}[[`FailureAnalysis`]. Spring
30+ Boot provides such analyzer for application context related exceptions, JSR-303
31+ validations and more. It is actually very easy to create your own.
32+
33+ `AbstractFailureAnalyzer` is a convenient extension of `FailureAnalyzer` that checks the
34+ presence of a specified exception type in the exception to handle. You can extend from
35+ that so that your implementation gets a chance to handle the exception only when it is
36+ actually present. If for whatever reason you can't handle the exception, return `null`
37+ to let another implementation a chance to handle the exception.
38+
39+ `FailureAnalyzer` implementations are to be registered in a `META-INF/spring.factories`:
40+ the following registers `ProjectConstraintViolationFailureAnalyzer`:
41+
42+ [source,properties,indent=0]
43+ ----
44+ org.springframework.boot.diagnostics.FailureAnalyzer=\
45+ com.example.ProjectConstraintViolationFailureAnalyzer
46+ ----
47+
48+
2549
2650[[howto-troubleshoot-auto-configuration]]
2751=== Troubleshoot auto-configuration
0 commit comments