From 46efd930f066c4b61b951d66697fd194b406f79d Mon Sep 17 00:00:00 2001 From: rstoyanchev Date: Tue, 6 Jan 2026 18:58:45 +0000 Subject: [PATCH] Update docs On the order of a ControllerAdvice that overrides the handling of built-in exceptions in a scenario with Boot autoconfig. Closes gh-35982 --- .../ROOT/pages/web/webflux/ann-rest-exceptions.adoc | 7 +++++++ .../ROOT/pages/web/webmvc/mvc-ann-rest-exceptions.adoc | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/framework-docs/modules/ROOT/pages/web/webflux/ann-rest-exceptions.adoc b/framework-docs/modules/ROOT/pages/web/webflux/ann-rest-exceptions.adoc index 8b1e8adc958..e0ddefb1221 100644 --- a/framework-docs/modules/ROOT/pages/web/webflux/ann-rest-exceptions.adoc +++ b/framework-docs/modules/ROOT/pages/web/webflux/ann-rest-exceptions.adoc @@ -66,6 +66,13 @@ from an existing `ProblemDetail`. This could be done centrally, for example, fro `@ControllerAdvice` such as `ResponseEntityExceptionHandler` that re-creates the `ProblemDetail` of an exception into a subclass with the additional non-standard fields. +TIP: In Spring Boot, the `spring.webflux.problemdetails.enabled` property autoconfigures +a `ResponseEntityExceptionHandler` that handles built-in exceptions with problem details. +In that case, you may prefer to create another `@ControllerAdvice` instead of extending +`ResponseEntityExceptionHandler` if you want to take over the handling of a specific +built-in exception. You'll need to ensure your handler is ordered ahead of the one +configured by Spring Boot whose order is 0. + [[webflux-ann-rest-exceptions-i18n]] == Customization and i18n diff --git a/framework-docs/modules/ROOT/pages/web/webmvc/mvc-ann-rest-exceptions.adoc b/framework-docs/modules/ROOT/pages/web/webmvc/mvc-ann-rest-exceptions.adoc index 1940ebaa780..c9eabd6e251 100644 --- a/framework-docs/modules/ROOT/pages/web/webmvc/mvc-ann-rest-exceptions.adoc +++ b/framework-docs/modules/ROOT/pages/web/webmvc/mvc-ann-rest-exceptions.adoc @@ -66,6 +66,13 @@ from an existing `ProblemDetail`. This could be done centrally, for example, fro `@ControllerAdvice` such as `ResponseEntityExceptionHandler` that re-creates the `ProblemDetail` of an exception into a subclass with the additional non-standard fields. +TIP: In Spring Boot, the `spring.mvc.problemdetails.enabled` property autoconfigures +a `ResponseEntityExceptionHandler` that handles built-in exceptions with problem details. +In that case, you may prefer to create another `@ControllerAdvice` instead of extending +`ResponseEntityExceptionHandler` if you want to take over the handling of a specific +built-in exception. You'll need to ensure your handler is ordered ahead of the one +configured by Spring Boot whose order is 0. + [[mvc-ann-rest-exceptions-i18n]] == Customization and i18n