Class OpenLogException

All Implemented Interfaces:
Serializable

public class OpenLogException extends OpenException
Open Log Exception - Logging Component Exception Open 日志异常 - 日志组件异常

This exception is thrown when errors occur during logging operations, such as provider initialization failures or configuration errors.

当日志操作期间发生错误时抛出此异常,如提供者初始化失败或配置错误。

Features | 主要功能:

  • Base exception for logging component errors - 日志组件错误的基础异常
  • Factory methods for common error scenarios - 常见错误场景的工厂方法
  • Extends OpenException with LOG component code - 继承 OpenException,使用 LOG 组件代码

Usage Examples | 使用示例:

// Throw provider not found
throw OpenLogException.providerNotFound();

// Throw initialization failure
throw OpenLogException.initializationFailed(cause);

// Throw invalid config
throw OpenLogException.invalidConfig("level", "Invalid log level");

Security | 安全性:

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

    • OpenLogException

      public OpenLogException(String message)
      Constructs a new exception with the specified message. 使用指定消息构造新异常。
      Parameters:
      message - the detail message - 详细消息
    • OpenLogException

      public OpenLogException(String message, Throwable cause)
      Constructs a new exception with the specified message and cause. 使用指定消息和原因构造新异常。
      Parameters:
      message - the detail message - 详细消息
      cause - the cause - 原因
  • Method Details

    • providerNotFound

      public static OpenLogException providerNotFound()
      Creates a provider not found exception. 创建提供者未找到异常。
      Returns:
      the exception - 异常
    • initializationFailed

      public static OpenLogException initializationFailed(Throwable cause)
      Creates an initialization failed exception. 创建初始化失败异常。
      Parameters:
      cause - the cause - 原因
      Returns:
      the exception - 异常
    • invalidConfig

      public static OpenLogException invalidConfig(String configKey, String message)
      Creates an invalid configuration exception. 创建无效配置异常。
      Parameters:
      configKey - the configuration key - 配置键
      message - the error message - 错误消息
      Returns:
      the exception - 异常
    • adapterNotFound

      public static OpenLogException adapterNotFound(String adapterType)
      Creates an adapter not found exception. 创建适配器未找到异常。
      Parameters:
      adapterType - the adapter type - 适配器类型
      Returns:
      the exception - 异常
    • unsupportedOperation

      public static OpenLogException unsupportedOperation(String operation)
      Creates an unsupported operation exception. 创建不支持的操作异常。
      Parameters:
      operation - the operation - 操作
      Returns:
      the exception - 异常