Class OpenBizException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
cloud.opencode.base.core.exception.OpenException
cloud.opencode.base.web.exception.OpenWebException
cloud.opencode.base.web.exception.OpenBizException
- All Implemented Interfaces:
Serializable
Open Business Exception
业务异常
Exception for business logic errors.
业务逻辑错误的异常。
Features | 主要功能:
- Business error with attached data - 带附加数据的业务错误
- Factory methods for common business errors - 常见业务错误的工厂方法
- Extends OpenWebException with data payload - 扩展 OpenWebException 并携带数据负载
- ResultCode integration - ResultCode 集成
Usage Examples | 使用示例:
// Using factory methods
throw OpenBizException.dataNotFound("User not found");
throw OpenBizException.dataDuplicate("Email already exists");
throw OpenBizException.validationError("Invalid input", errors);
// With result code
throw new OpenBizException(CommonResultCode.BUSINESS_ERROR);
Security | 安全性:
- Thread-safe: Yes (immutable fields) - 线程安全: 是(不可变字段)
- Null-safe: No (message should not be null) - 空值安全: 否(消息不应为 null)
- Since:
- JDK 25, opencode-base-web V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionOpenBizException(ResultCode resultCode) Create exception with result code 使用响应码创建异常OpenBizException(ResultCode resultCode, Object data) Create exception with result code and data 使用响应码和数据创建异常OpenBizException(ResultCode resultCode, String message) Create exception with result code and custom message 使用响应码和自定义消息创建异常OpenBizException(ResultCode resultCode, Throwable cause) Create exception with result code and cause 使用响应码和原因创建异常OpenBizException(String message) Create exception with message 使用消息创建异常OpenBizException(String code, String message) Create exception with code and message 使用代码和消息创建异常OpenBizException(String code, String message, Object data) Create exception with code, message and data 使用代码、消息和数据创建异常OpenBizException(String message, Throwable cause) Create exception with message and cause 使用消息和原因创建异常 -
Method Summary
Modifier and TypeMethodDescriptionstatic OpenBizExceptiondataDuplicate(String message) Create data duplicate exception 创建数据重复异常static OpenBizExceptiondataNotFound(String message) Create data not found exception 创建数据不存在异常getData()Get the data 获取数据static OpenBizExceptionoperationFailed(String message) Create operation failed exception 创建操作失败异常static OpenBizExceptionvalidationError(String message) Create validation error exception 创建验证错误异常static OpenBizExceptionvalidationError(String message, Object errors) Create validation error exception with data 创建带数据的验证错误异常Methods inherited from class OpenWebException
badRequest, forbidden, getCode, getHttpStatus, getMessage, internalError, internalError, notFound, unauthorizedMethods inherited from class OpenException
getComponent, getErrorCode, getRawMessageMethods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
OpenBizException
Create exception with message 使用消息创建异常- Parameters:
message- the message | 消息
-
OpenBizException
-
OpenBizException
Create exception with result code 使用响应码创建异常- Parameters:
resultCode- the result code | 响应码
-
OpenBizException
Create exception with result code and custom message 使用响应码和自定义消息创建异常- Parameters:
resultCode- the result code | 响应码message- the custom message | 自定义消息
-
OpenBizException
Create exception with result code and data 使用响应码和数据创建异常- Parameters:
resultCode- the result code | 响应码data- the data | 数据
-
OpenBizException
-
OpenBizException
-
OpenBizException
Create exception with result code and cause 使用响应码和原因创建异常- Parameters:
resultCode- the result code | 响应码cause- the cause | 原因
-
-
Method Details
-
getData
-
dataNotFound
Create data not found exception 创建数据不存在异常- Parameters:
message- the message | 消息- Returns:
- the exception | 异常
-
dataDuplicate
Create data duplicate exception 创建数据重复异常- Parameters:
message- the message | 消息- Returns:
- the exception | 异常
-
operationFailed
Create operation failed exception 创建操作失败异常- Parameters:
message- the message | 消息- Returns:
- the exception | 异常
-
validationError
Create validation error exception 创建验证错误异常- Parameters:
message- the message | 消息- Returns:
- the exception | 异常
-
validationError
Create validation error exception with data 创建带数据的验证错误异常- Parameters:
message- the message | 消息errors- the validation errors | 验证错误- Returns:
- the exception | 异常
-