Spring MVC异常处理

Restlight for Spring MVC支持使用Spring MVC中的@ExceptionHandler, @ControllerAdvice等注解,并且对此能力进行了增强 参考ExceptionHandler支持

ExceptionResolver

eg.

处理RuntimeException

@Component
public class GlobalExceptionResolver implements ExceptionResolver<RuntimeException> {

    @Override
    public CompletionStage<Void> handleException(RequestContext context, RuntimeException e) {
        // handle exception here
        return CompletableFuture.completedFuture(null);
    }

}