Class OpenCronException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
cloud.opencode.base.core.exception.OpenException
cloud.opencode.base.cron.exception.OpenCronException
- All Implemented Interfaces:
OpenExceptionMeta, Serializable
Cron Exception - Exception for Cron Expression Errors
Cron异常 - Cron表达式错误异常
Thrown when cron expression parsing, validation, or evaluation fails.
Extends OpenException to maintain consistent exception hierarchy.
Carries diagnostic context including the original expression and the
problematic field name.
当Cron表达式解析、验证或计算失败时抛出。
继承 OpenException 以保持一致的异常体系。
携带诊断上下文,包括原始表达式和有问题的字段名称。
Features | 主要功能:
- Extends OpenException for unified hierarchy - 继承OpenException统一异常体系
- Diagnostic fields: expression, field name - 诊断字段:表达式、字段名称
- Factory methods for common error types - 常见错误类型的工厂方法
- Serializable - 可序列化
Usage Examples | 使用示例:
throw OpenCronException.parseError("invalid", "expected 5 or 6 fields");
throw OpenCronException.fieldError("hour", 25, 0, 23);
Security | 安全性:
- Thread-safe: Yes (immutable exception) - 线程安全: 是(不可变异常)
- Null-safe: No - 空值安全: 否
- Since:
- JDK 25, opencode-base-cron V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionOpenCronException(String message) Constructs exception with message 构造带消息的异常OpenCronException(String message, String expression, String field, Throwable cause) Constructs exception with all diagnostic fields 构造带所有诊断字段的异常OpenCronException(String message, Throwable cause) Constructs exception with message and cause 构造带消息和原因的异常 -
Method Summary
Modifier and TypeMethodDescriptionstatic OpenCronExceptionfieldError(String field, int value, int min, int max) Creates exception for invalid field values 为无效字段值创建异常static OpenCronExceptionfieldError(String field, String fieldValue, String reason) Creates exception for invalid field expression 为无效字段表达式创建异常Gets the cron expression that caused the error 获取导致错误的Cron表达式getField()Gets the problematic field name 获取有问题的字段名称static OpenCronExceptionparseError(String expression, String reason) Creates exception for parse errors 为解析错误创建异常static OpenCronExceptionparseError(String expression, String reason, Throwable cause) Creates exception for parse errors with cause 为带原因的解析错误创建异常static OpenCronExceptionunknownMacro(String macro) Creates exception for unknown macro 为未知宏创建异常Methods inherited from class OpenException
getComponent, getErrorCode, getMessage, getRawMessageMethods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface OpenExceptionMeta
getMetaPrefix
-
Constructor Details
-
OpenCronException
Constructs exception with message 构造带消息的异常- Parameters:
message- the detail message | 详细消息
-
OpenCronException
-
OpenCronException
Constructs exception with all diagnostic fields 构造带所有诊断字段的异常- Parameters:
message- the detail message | 详细消息expression- the cron expression | Cron表达式field- the problematic field | 有问题的字段cause- the cause | 原因
-
-
Method Details
-
getExpression
Gets the cron expression that caused the error 获取导致错误的Cron表达式- Returns:
- the expression, or null | 表达式,或null
-
getField
Gets the problematic field name 获取有问题的字段名称- Returns:
- the field name, or null | 字段名称,或null
-
parseError
Creates exception for parse errors 为解析错误创建异常- Parameters:
expression- the expression | 表达式reason- the reason | 原因- Returns:
- the exception | 异常
-
parseError
Creates exception for parse errors with cause 为带原因的解析错误创建异常- Parameters:
expression- the expression | 表达式reason- the reason | 原因cause- the cause | 原因- Returns:
- the exception | 异常
-
fieldError
Creates exception for invalid field values 为无效字段值创建异常- Parameters:
field- the field name | 字段名称value- the invalid value | 无效值min- the minimum allowed value | 允许的最小值max- the maximum allowed value | 允许的最大值- Returns:
- the exception | 异常
-
fieldError
Creates exception for invalid field expression 为无效字段表达式创建异常- Parameters:
field- the field name | 字段名称fieldValue- the invalid field value | 无效字段值reason- the reason | 原因- Returns:
- the exception | 异常
-
unknownMacro
Creates exception for unknown macro 为未知宏创建异常- Parameters:
macro- the unknown macro | 未知宏- Returns:
- the exception | 异常
-