io.github.unickcheng.rhandler.exception.ExceptionHandlerAdvice Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of response-handler-core Show documentation
Show all versions of response-handler-core Show documentation
The core module which supports RESTful API, exception handler, openapi
The newest version!
/*
* create on 2023-01-08
* GitHub https://github.com/UNICKCHENG/Response-Handler
*/
package io.github.unickcheng.rhandler.exception;
import io.github.unickcheng.rhandler.response.ResponseResult;
import io.github.unickcheng.rhandler.utils.LogInfo;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.lang.Nullable;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
import javax.validation.constraints.NotNull;
/**
* 通用异常拦截器
* @see ResponseEntityExceptionHandler 作为其他异常捕获,注意目前只收集了 15 种异常情形
* @see #exception(Exception, WebRequest) 添加指定的异常拦截样例
* @see RHandlerException 自定义异常封装类
* @author unickcheng
*/
@RestControllerAdvice
public class ExceptionHandlerAdvice extends ResponseEntityExceptionHandler {
@Override
protected ResponseEntity