Package org.springframework.web.reactive
Class HandlerResult
java.lang.Object
org.springframework.web.reactive.HandlerResult
Represent the result of the invocation of a handler or a handler method.
- Since:
- 5.0
- Author:
- Rossen Stoyanchev
-
Constructor Summary
ConstructorDescriptionHandlerResult
(Object handler, Object returnValue, MethodParameter returnType) Create a newHandlerResult
.HandlerResult
(Object handler, Object returnValue, MethodParameter returnType, BindingContext context) Create a newHandlerResult
. -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<HandlerResult>
applyExceptionHandler
(Throwable failure) Deprecated, for removal: This API element is subject to removal in a future version.without a replacement; for internal invocation only, not used as of 6.0Return the BindingContext used for request handling.Return theconfigured
exception handler.Return the handler that handled the request.getModel()
Return the model used for request handling.Return the type of the value returned from the handler -- e.g.Return theMethodParameter
from whichreturnType
was created.Return the value returned from the handler, if any.boolean
Deprecated, for removal: This API element is subject to removal in a future version.in favor of checking viagetExceptionHandler()
setExceptionHandler
(Function<Throwable, reactor.core.publisher.Mono<HandlerResult>> function) Deprecated, for removal: This API element is subject to removal in a future version.in favor ofsetExceptionHandler(DispatchExceptionHandler)
setExceptionHandler
(DispatchExceptionHandler exceptionHandler) AHandlerAdapter
may use this to provide an exception handler to use to map exceptions from handling this result into an alternative one.
-
Constructor Details
-
HandlerResult
Create a newHandlerResult
.- Parameters:
handler
- the handler that handled the requestreturnValue
- the return value from the handler possiblynull
returnType
- the return value type
-
HandlerResult
public HandlerResult(Object handler, @Nullable Object returnValue, MethodParameter returnType, @Nullable BindingContext context) Create a newHandlerResult
.- Parameters:
handler
- the handler that handled the requestreturnValue
- the return value from the handler possiblynull
returnType
- the return value typecontext
- the binding context used for request handling
-
-
Method Details
-
getHandler
Return the handler that handled the request. -
getReturnValue
Return the value returned from the handler, if any. -
getReturnType
Return the type of the value returned from the handler -- e.g. the return type declared on a controller method's signature. Also seegetReturnTypeSource()
to obtain the underlyingMethodParameter
for the return type. -
getReturnTypeSource
Return theMethodParameter
from whichreturnType
was created. -
getBindingContext
Return the BindingContext used for request handling. -
getModel
Return the model used for request handling. This is a shortcut forgetBindingContext().getModel()
. -
setExceptionHandler
AHandlerAdapter
may use this to provide an exception handler to use to map exceptions from handling this result into an alternative one. Especially when the return value is asynchronous, an exception is not be produced at the point of handler invocation, but rather later when result handling causes the actual value or an exception to be produced.- Parameters:
exceptionHandler
- the exception handler to use- Since:
- 6.0
-
getExceptionHandler
Return theconfigured
exception handler.- Since:
- 6.0
-
setExceptionHandler
@Deprecated(since="6.0", forRemoval=true) public HandlerResult setExceptionHandler(Function<Throwable, reactor.core.publisher.Mono<HandlerResult>> function) Deprecated, for removal: This API element is subject to removal in a future version.in favor ofsetExceptionHandler(DispatchExceptionHandler)
Configure an exception handler that may be used to produce an alternative result when result handling fails. Especially for an async return value errors may occur after the invocation of the handler.- Parameters:
function
- the error handler- Returns:
- the current instance
-
hasExceptionHandler
Deprecated, for removal: This API element is subject to removal in a future version.in favor of checking viagetExceptionHandler()
Whether there is an exception handler. -
applyExceptionHandler
@Deprecated(since="6.0", forRemoval=true) public reactor.core.publisher.Mono<HandlerResult> applyExceptionHandler(Throwable failure) Deprecated, for removal: This API element is subject to removal in a future version.without a replacement; for internal invocation only, not used as of 6.0Apply the exception handler and return the alternative result.- Parameters:
failure
- the exception- Returns:
- the new result or the same error if there is no exception handler
-