Class OpenLockException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
cloud.opencode.base.core.exception.OpenException
cloud.opencode.base.lock.exception.OpenLockException
- All Implemented Interfaces:
OpenExceptionMeta, Serializable
- Direct Known Subclasses:
OpenLockAcquireException, OpenLockTimeoutException
Base Lock Exception for All Lock-Related Errors
所有锁相关错误的基础锁异常
Base exception class for all lock-related errors in the lock component, providing detailed error information including lock name and error type.
锁组件中所有锁相关错误的基础异常类,提供包括锁名称和错误类型的详细错误信息。
Features | 主要功能:
- Lock name tracking - 锁名称跟踪
- Error type classification - 错误类型分类
- Cause chaining - 原因链
- Component identification - 组件标识
Error Types | 错误类型:
- GENERAL - General lock errors | 一般锁错误
- TIMEOUT - Lock acquisition timeout | 锁获取超时
- ACQUIRE - Lock acquisition failure | 锁获取失败
- RELEASE - Lock release failure | 锁释放失败
- EXPIRED - Lock expired | 锁已过期
- NOT_HELD - Lock not held by thread | 线程未持有锁
- DEADLOCK - Deadlock detected | 检测到死锁
- INTERRUPTED - Thread interrupted | 线程被中断
Usage Examples | 使用示例:
// Catch lock operation failures
// 捕获锁操作失败
try {
lock.lock();
} catch (OpenLockException e) {
log.error("Lock failed: {}", e.getMessage());
}
Security | 安全性:
- Thread-safe: Yes (immutable enum) - 线程安全: 是(不可变枚举)
- Null-safe: Yes - 空值安全: 是
- Since:
- JDK 25, opencode-base-lock V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumLock Error Type Enumeration 锁错误类型枚举 -
Constructor Summary
ConstructorsConstructorDescriptionOpenLockException(String message) Constructs a new lock exception with message 使用消息构造新的锁异常OpenLockException(String message, String lockName, OpenLockException.LockErrorType errorType) Constructs a new lock exception with full details 使用完整详情构造新的锁异常OpenLockException(String message, String lockName, OpenLockException.LockErrorType errorType, Throwable cause) Constructs a new lock exception with full details and cause 使用完整详情和原因构造新的锁异常OpenLockException(String message, Throwable cause) Constructs a new lock exception with message and cause 使用消息和原因构造新的锁异常 -
Method Summary
Modifier and TypeMethodDescriptionGets the type of lock error that occurred 获取发生的锁错误类型lockName()Gets the name of the lock that caused the exception 获取导致异常的锁名称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
-
OpenLockException
Constructs a new lock exception with message 使用消息构造新的锁异常- Parameters:
message- the error message | 错误消息
-
OpenLockException
-
OpenLockException
public OpenLockException(String message, String lockName, OpenLockException.LockErrorType errorType) Constructs a new lock exception with full details 使用完整详情构造新的锁异常- Parameters:
message- the error message | 错误消息lockName- the lock name | 锁名称errorType- the error type | 错误类型
-
OpenLockException
public OpenLockException(String message, String lockName, OpenLockException.LockErrorType errorType, Throwable cause) Constructs a new lock exception with full details and cause 使用完整详情和原因构造新的锁异常- Parameters:
message- the error message | 错误消息lockName- the lock name | 锁名称errorType- the error type | 错误类型cause- the cause | 原因
-
-
Method Details
-
lockName
Gets the name of the lock that caused the exception 获取导致异常的锁名称- Returns:
- the lock name, or null if not specified | 锁名称,如果未指定则为null
-
errorType
Gets the type of lock error that occurred 获取发生的锁错误类型- Returns:
- the error type | 错误类型
-