| 程序包 | 说明 |
|---|---|
| net.wenzuo.base.config | |
| net.wenzuo.base.util |
| 限定符和类型 | 方法和说明 |
|---|---|
Ret<Void> |
ExceptionConfig.handler(javax.validation.ConstraintViolationException e)
请求参数校验失败异常处理
即 @Valid 校验失败
|
Ret<Void> |
ExceptionConfig.handler(Exception e)
默认异常处理
|
Ret<Void> |
ExceptionConfig.handler(org.springframework.http.converter.HttpMessageNotReadableException e)
请求体不可读错误异常处理
如 要求接收一个 json 请求体, 但是未读取到
|
Ret<Void> |
ExceptionConfig.handler(org.springframework.web.HttpRequestMethodNotSupportedException e)
请求方法错误异常处理
即 POST 接口, 请求时用了 GET 方法
|
Ret<Void> |
ExceptionConfig.handler(org.springframework.web.bind.MethodArgumentNotValidException e)
请求参数校验失败异常处理
即 @Validated 校验失败
|
Ret<Void> |
ExceptionConfig.handler(org.springframework.web.method.annotation.MethodArgumentTypeMismatchException e)
请求参数类型不匹配异常处理
如要 Integer 参数, 却传了字符串, 且无法转换为 Integer eg: Failed to convert value of type 'java.lang.String' to
required type 'java.lang.Integer'; nested exception is java.lang.NumberFormatException: For input string: "hello"
|
Ret<Void> |
ExceptionConfig.handler(org.springframework.web.bind.MissingServletRequestParameterException e)
请求参数缺失异常处理
如要 name 字段, 却传递 eg: Required String parameter 'name' is not present
|
Ret<Void> |
ExceptionConfig.handler(ServiceException e)
业务异常处理
如支付失败
|
| 限定符和类型 | 方法和说明 |
|---|---|
static Ret<Void> |
Ret.badRequest() |
static Ret<Void> |
Ret.fail(int code,
String msg) |
static Ret<Void> |
Ret.fail(Retable ret) |
static Ret<Void> |
Ret.fail(String msg) |
static Ret<Void> |
Ret.fail(String template,
Object... values) |
static Ret<Void> |
Ret.forbidden() |
static Ret<Void> |
Ret.notFound() |
static <T> Ret<T> |
Ret.ok() |
static <T> Ret<T> |
Ret.ok(T data) |
static Ret<Void> |
Ret.serverError() |
static Ret<Void> |
Ret.unauthorized() |
Copyright © 2021. All rights reserved.