- All Implemented Interfaces:
Serializable, Comparable<StorageError>, java.lang.constant.Constable
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 ConstantsEnum ConstantDescriptionfatal: 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 bydescribe(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
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateStorageError(String label, boolean fatal) Describes one error condition.Method Summary
Modifier and TypeMethodDescriptionstatic StorageErrorclassify(IOException ioe) Classify a storage failure.static Stringdescribe(IOException ioe) Human-readable description of a storage failure, preserving the raw exception text for unclassified errors.booleanisFatal()Whether a torrent should stop on this failure rather than drop the request and retry.toString()Human-readable label for console and log messages.static StorageErrorReturns the enum constant of this class with the specified name.static StorageError[]values()Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class Enum
clone, compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, valueOf
Enum Constant Details
NO_SPACE
fatal: ENOSPC, the device has no free blocks left.PERMISSION
fatal: EACCES or EPERM, the torrent's paths are not writable.READ_ONLY
fatal: EROFS, the filesystem holding the torrent is mounted read-only.QUOTA
fatal: EDQUOT, the user's block quota on the filesystem is exhausted.IO_ERROR
fatal: EIO, the device reported an unrecoverable error.IS_DIRECTORY
fatal: EISDIR, a path that must name a file is a directory.NAME_TOO_LONG
fatal: ENAMETOOLONG, a path component exceeds the filesystem limit.TOO_MANY_OPEN
transient: fd exhaustion, retry.STALE_HANDLE
transient: stale or read-only handle, retry.MISSING
transient: file vanished, retry.OTHER
Unclassified error; the raw exception text is preserved bydescribe(IOException).
Field Details
label
Short name shown for this error.fatal
private final boolean fatalTrue when the error stops the download.
Constructor Details
StorageError
Describes one error condition.- Parameters:
label- the name shown to the userfatal- whether it stops the download
Method Details
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
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 nameNullPointerException- if the argument is null
toString
Human-readable label for console and log messages.- Overrides:
toStringin classEnum<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
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
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