异常代码优化

This commit is contained in:
lqyan
2024-02-19 11:36:36 +08:00
parent 40bf18c65f
commit bef820a65c
2 changed files with 7 additions and 46 deletions

View File

@@ -1,5 +1,7 @@
package com.jhinno.sdk.openapi;
import lombok.Getter;
/**
* <p>
* 这个异常是客户端访问景行API时抛出的异常。
@@ -20,6 +22,7 @@ package com.jhinno.sdk.openapi;
* @author yanlongqi
* @date 2024/1/30 11:27
*/
@Getter
public class ClientException extends RuntimeException {
@@ -94,24 +97,6 @@ public class ClientException extends RuntimeException {
this.errorCode = errorCode;
}
/**
* 获取错误代码。
*
* @return 错误代码
*/
public String getErrorCode() {
return errorCode;
}
/**
* 获取错误消息。
*
* @return 字符串中的错误消息
*/
public String getErrorMessage() {
return errorMessage;
}
@Override
public String getMessage() {
return String.format("%s\n[ErrorCode]: %s", getErrorMessage(), errorCode != null ? errorCode : "");

View File

@@ -1,5 +1,7 @@
package com.jhinno.sdk.openapi;
import lombok.Getter;
/**
* <p>
* 这是表示任何预期或意外的景行API服务器端错误的基本异常类。
@@ -26,6 +28,7 @@ package com.jhinno.sdk.openapi;
* @author yanlongqi
* @date 2024/1/30 11:35
*/
@Getter
public class ServiceException extends RuntimeException {
/**
@@ -79,33 +82,6 @@ public class ServiceException extends RuntimeException {
}
/**
* 获取请求码
*
* @return 请求码
*/
public int getErrorCode() {
return errorCode;
}
/**
* 获取错信息
*
* @return 错误信息
*/
public String getErrorMessage() {
return errorMessage;
}
/**
* 获取请求路径
*
* @return 请求路径
*/
public String getRequestPath() {
return requestPath;
}
@Override
public String getMessage() {
return String.format("%s\n[请求路径]: %s\n[错误码]: %s", errorMessage, requestPath, errorCode);