Class ImageFormatException

All Implemented Interfaces:
OpenExceptionMeta, Serializable

public class ImageFormatException extends ImageException
Image Format Exception 图片格式异常

Exception thrown when image format is invalid or unsupported.

当图片格式无效或不支持时抛出的异常。

Features | 主要功能:

  • Exception for invalid or unsupported image formats - 无效或不支持的图片格式的异常
  • Carries ImageErrorCode for programmatic error handling - 携带 ImageErrorCode 用于编程式错误处理

Usage Examples | 使用示例:

// Catch specific exception
try {
    OpenImage.read(path);
} catch (ImageFormatException e) {
    System.err.println(e.getMessage());
}

Security | 安全性:

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

    • ImageFormatException

      public ImageFormatException(String message)
      Create an image format exception 创建图片格式异常
      Parameters:
      message - the error message | 错误消息
    • ImageFormatException

      public ImageFormatException(String message, String format)
      Create an image format exception with format 创建带格式的图片格式异常
      Parameters:
      message - the error message | 错误消息
      format - the image format | 图片格式
    • ImageFormatException

      public ImageFormatException(String message, ImageErrorCode errorCode)
      Create an image format exception with error code 创建带错误码的图片格式异常
      Parameters:
      message - the error message | 错误消息
      errorCode - the error code | 错误码
    • ImageFormatException

      public ImageFormatException(String message, Throwable cause)
      Create an image format exception with cause 创建带原因的图片格式异常
      Parameters:
      message - the error message | 错误消息
      cause - the cause | 原因
  • Method Details

    • unsupported

      public static ImageFormatException unsupported(String format)
      Create exception for unsupported format 创建不支持格式的异常
      Parameters:
      format - the unsupported format | 不支持的格式
      Returns:
      the exception | 异常
    • getFormat

      public String getFormat()
      Get the format 获取格式
      Returns:
      the format or null | 格式或null