java.lang.Object
java.lang.Enum<StorageError>
org.klomp.snark.StorageError
All Implemented Interfaces:
Serializable, Comparable<StorageError>, java.lang.constant.Constable

public enum StorageErrorextends Enum<StorageError>
Classified storage failures. The JDK maps many errno failures to typed NIO exceptions, so those are matched first without any message parsing; the OS error text carried by the exception message is only a fallback for classic java.io failures (RandomAccessFile paths surface as plain IOException) and for errno cases with no typed exception (ENOSPC, EIO, EMFILE, EDQUOT, ...).

Each constant carries the human-readable label used in console and log messages, and whether the failure is fatal for the torrent (stop) or transient (drop the request and retry later).

  • Nested Class Summary

    Nested classes/interfaces inherited from class Enum

    Enum.EnumDesc<E>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    fatal: EIO, the device reported an unrecoverable error.
    fatal: EISDIR, a path that must name a file is a directory.
    transient: file vanished, retry.
    fatal: ENAMETOOLONG, a path component exceeds the filesystem limit.
    fatal: ENOSPC, the device has no free blocks left.
    Unclassified error; the raw exception text is preserved by describe(IOException).
    fatal: EACCES or EPERM, the torrent's paths are not writable.
    fatal: EDQUOT, the user's block quota on the filesystem is exhausted.
    fatal: EROFS, the filesystem holding the torrent is mounted read-only.
    transient: stale or read-only handle, retry.
    transient: fd exhaustion, retry.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final boolean
    True when the error stops the download.
    private final String
    Short name shown for this error.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    StorageError(String label, boolean fatal)
    Describes one error condition.
  • Method Summary

    Modifier and Type
    Method
    Description
    Classify a storage failure.
    static String
    Human-readable description of a storage failure, preserving the raw exception text for unclassified errors.
    boolean
    Whether a torrent should stop on this failure rather than drop the request and retry.
    Human-readable label for console and log messages.
    Returns the enum constant of this class with the specified name.
    static StorageError[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • NO_SPACE

      public static final StorageError NO_SPACE
      fatal: ENOSPC, the device has no free blocks left.
    • PERMISSION

      public static final StorageError PERMISSION
      fatal: EACCES or EPERM, the torrent's paths are not writable.
    • READ_ONLY

      public static final StorageError READ_ONLY
      fatal: EROFS, the filesystem holding the torrent is mounted read-only.
    • QUOTA

      public static final StorageError QUOTA
      fatal: EDQUOT, the user's block quota on the filesystem is exhausted.
    • IO_ERROR

      public static final StorageError IO_ERROR
      fatal: EIO, the device reported an unrecoverable error.
    • IS_DIRECTORY

      public static final StorageError IS_DIRECTORY
      fatal: EISDIR, a path that must name a file is a directory.
    • NAME_TOO_LONG

      public static final StorageError NAME_TOO_LONG
      fatal: ENAMETOOLONG, a path component exceeds the filesystem limit.
    • TOO_MANY_OPEN

      public static final StorageError TOO_MANY_OPEN
      transient: fd exhaustion, retry.
    • STALE_HANDLE

      public static final StorageError STALE_HANDLE
      transient: stale or read-only handle, retry.
    • MISSING

      public static final StorageError MISSING
      transient: file vanished, retry.
    • OTHER

      public static final StorageError OTHER
      Unclassified error; the raw exception text is preserved by describe(IOException).
  • Field Details

    • label

      private final String label
      Short name shown for this error.
    • fatal

      private final boolean fatal
      True when the error stops the download.
  • Constructor Details

    • StorageError

      private StorageError(String label, boolean fatal)
      Describes one error condition.
      Parameters:
      label - the name shown to the user
      fatal - whether it stops the download
  • Method Details

    • values

      public static StorageError[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static StorageError valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • toString

      public String toString()
      Human-readable label for console and log messages.
      Overrides:
      toString in class Enum<StorageError>
    • isFatal

      public boolean isFatal()
      Whether a torrent should stop on this failure rather than drop the request and retry.
      Returns:
      true if the torrent must stop, false if the failed request may be dropped and retried
    • classify

      public static StorageError classify(IOException ioe)
      Classify a storage failure. Typed NIO exceptions map directly; otherwise the errno text is matched case-insensitively, using the JVM's canonical English messages for Unix and Windows.
      Parameters:
      ioe - the storage error
      Returns:
      the classified error, never null
    • describe

      public static String describe(IOException ioe)
      Human-readable description of a storage failure, preserving the raw exception text for unclassified errors.
      Parameters:
      ioe - the storage error
      Returns:
      the classification's own text when the message could be matched, otherwise the raw message prefixed with "I/O error", or just that prefix if the message is null