Example usage for org.springframework.web.reactive.result.method InvocableHandlerMethod getMethod

List of usage examples for org.springframework.web.reactive.result.method InvocableHandlerMethod getMethod

Introduction

In this page you can find the example usage for org.springframework.web.reactive.result.method InvocableHandlerMethod getMethod.

Prototype

public Method getMethod() 

Source Link

Document

Return the method for this handler method.

Usage

From source file:org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter.java

private Mono<HandlerResult> handleException(Throwable exception, HandlerMethod handlerMethod,
        BindingContext bindingContext, ServerWebExchange exchange) {

    Assert.state(this.methodResolver != null, "Not initialized");

    InvocableHandlerMethod invocable = this.methodResolver.getExceptionHandlerMethod(exception, handlerMethod);
    if (invocable != null) {
        try {//from w  w w . ja v  a  2s  . c  o  m
            if (logger.isDebugEnabled()) {
                logger.debug("Invoking @ExceptionHandler method: " + invocable.getMethod());
            }
            bindingContext.getModel().asMap().clear();
            Throwable cause = exception.getCause();
            if (cause != null) {
                return invocable.invoke(exchange, bindingContext, exception, cause, handlerMethod);
            } else {
                return invocable.invoke(exchange, bindingContext, exception, handlerMethod);
            }
        } catch (Throwable invocationEx) {
            if (logger.isWarnEnabled()) {
                logger.warn("Failed to invoke: " + invocable.getMethod(), invocationEx);
            }
        }
    }
    return Mono.error(exception);
}