Class OpenHashException

All Implemented Interfaces:
OpenExceptionMeta, Serializable

public class OpenHashException extends OpenException
Hash operation exception 哈希操作异常

Exception thrown when hash operations fail, including algorithm not supported, invalid input, illegal state, and other hash-related errors.

哈希操作失败时抛出的异常,包括算法不支持、无效输入、非法状态和其他哈希相关错误。

Features | 主要功能:

  • Algorithm information - 算法信息
  • Operation context - 操作上下文
  • Factory methods for common errors - 常见错误的工厂方法

Usage Examples | 使用示例:

// Catch hash operation failures
// 捕获哈希操作失败
try {
    hashFunction.hash(data);
} catch (OpenHashException e) {
    log.error("Hash failed: {}", e.getMessage());
}

Security | 安全性:

  • Thread-safe: Yes (immutable exception) - 线程安全: 是(不可变异常)
  • Null-safe: No - 空值安全: 否
Since:
JDK 25, opencode-base-hash V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • OpenHashException

      public OpenHashException(String message)
      Creates exception with message 使用消息创建异常
      Parameters:
      message - error message | 错误消息
    • OpenHashException

      public OpenHashException(String message, Throwable cause)
      Creates exception with message and cause 使用消息和原因创建异常
      Parameters:
      message - error message | 错误消息
      cause - underlying cause | 底层原因
    • OpenHashException

      public OpenHashException(String algorithm, String operation, String message)
      Creates exception with algorithm and operation context 使用算法和操作上下文创建异常
      Parameters:
      algorithm - algorithm name | 算法名称
      operation - operation type | 操作类型
      message - error message | 错误消息
    • OpenHashException

      public OpenHashException(String algorithm, String operation, String message, Throwable cause)
      Creates exception with algorithm, operation, and cause 使用算法、操作和原因创建异常
      Parameters:
      algorithm - algorithm name | 算法名称
      operation - operation type | 操作类型
      message - error message | 错误消息
      cause - underlying cause | 底层原因
  • Method Details

    • algorithm

      public String algorithm()
      Gets the algorithm name 获取算法名称
      Returns:
      algorithm name or null | 算法名称或null
    • operation

      public String operation()
      Gets the operation type 获取操作类型
      Returns:
      operation type or null | 操作类型或null
    • algorithmNotSupported

      public static OpenHashException algorithmNotSupported(String algorithm)
      Creates an algorithm not supported exception 创建算法不支持异常
      Parameters:
      algorithm - the unsupported algorithm | 不支持的算法
      Returns:
      exception instance | 异常实例
    • invalidInput

      public static OpenHashException invalidInput(String message)
      Creates an invalid input exception 创建无效输入异常
      Parameters:
      message - error message | 错误消息
      Returns:
      exception instance | 异常实例
    • illegalState

      public static OpenHashException illegalState(String message)
      Creates an illegal state exception 创建非法状态异常
      Parameters:
      message - error message | 错误消息
      Returns:
      exception instance | 异常实例
    • hashFailed

      public static OpenHashException hashFailed(String algorithm, Throwable cause)
      Creates a hash computation failed exception 创建哈希计算失败异常
      Parameters:
      algorithm - algorithm name | 算法名称
      cause - underlying cause | 底层原因
      Returns:
      exception instance | 异常实例
    • invalidBloomFilterConfig

      public static OpenHashException invalidBloomFilterConfig(String reason)
      Creates an invalid bloom filter configuration exception 创建无效布隆过滤器配置异常
      Parameters:
      reason - the reason | 原因
      Returns:
      exception instance | 异常实例
    • nodeNotFound

      public static OpenHashException nodeNotFound(String nodeId)
      Creates a node not found exception 创建节点不存在异常
      Parameters:
      nodeId - node id | 节点ID
      Returns:
      exception instance | 异常实例
    • hasherAlreadyUsed

      public static OpenHashException hasherAlreadyUsed()
      Creates a hasher already used exception 创建Hasher已使用异常
      Returns:
      exception instance | 异常实例
    • hmacFailed

      public static OpenHashException hmacFailed(String algorithm, Throwable cause)
      Creates an HMAC computation failed exception 创建HMAC计算失败异常
      Parameters:
      algorithm - algorithm name | 算法名称
      cause - underlying cause | 底层原因
      Returns:
      exception instance | 异常实例