Skip to content

Commit 479a53b

Browse files
committed
Update docs on DispatcherHandler exception handling
See gh-22991
1 parent 0348a7b commit 479a53b

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

framework-docs/src/docs/asciidoc/web/webflux.adoc

+9-11
Original file line numberDiff line numberDiff line change
@@ -1168,19 +1168,17 @@ as a `HandlerResult`, along with some additional context, and passed to the firs
11681168
=== Exceptions
11691169
[.small]#<<web.adoc#mvc-exceptionhandlers, Web MVC>>#
11701170

1171-
The `HandlerResult` returned from a `HandlerAdapter` can expose a function for error
1172-
handling based on some handler-specific mechanism. This error function is called if:
1171+
`HandlerAdapter` implementations can handle internally exceptions from invoking a request
1172+
handler, such as a controller method. However, an exception may be deferred if the request
1173+
handler returns an asynchronous value.
11731174

1174-
* The handler (for example, `@Controller`) invocation fails.
1175-
* The handling of the handler return value through a `HandlerResultHandler` fails.
1175+
A `HandlerAdapter` may expose its exception handling mechanism as a
1176+
`DispatchExceptionHandler` set on the `HandlerResult` it returns. When that's set,
1177+
`DispatcherHandler` will also apply it to the handling of the result.
11761178

1177-
The error function can change the response (for example, to an error status), as long as an error
1178-
signal occurs before the reactive type returned from the handler produces any data items.
1179-
1180-
This is how `@ExceptionHandler` methods in `@Controller` classes are supported.
1181-
By contrast, support for the same in Spring MVC is built on a `HandlerExceptionResolver`.
1182-
This generally should not matter. However, keep in mind that, in WebFlux, you cannot use a
1183-
`@ControllerAdvice` to handle exceptions that occur before a handler is chosen.
1179+
A `HandlerAdapter` may also choose to implement `DispatchExceptionHandler`. Inn that case
1180+
`DispatcherHandler` will apply it to exceptions that arise before a handler is mapped,
1181+
e.g. during handler mapping, or earlier, e.g. in a `WebFilter`.
11841182

11851183
See also <<webflux-ann-controller-exceptions>> in the "`Annotated Controller`" section or
11861184
<<webflux-exception-handler>> in the WebHandler API section.

0 commit comments

Comments
 (0)