Class ModuleException
java.lang.Object
java.lang.Throwable
java.lang.Exception
dev.jcputney.elearning.parser.exception.ModuleException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
FileAccessException,ManifestParseException,ModuleDetectionException,ModuleParsingException
Base exception class for all module-related exceptions in the elearning-module-parser library.
This class provides a foundation for a more extensible error handling framework by:
- Establishing a common base class for all module-related exceptions
- Supporting additional context information through a metadata map
- Providing consistent constructors and methods across all exception types
All specific exception types in the library should extend this class or one of its subclasses.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionModuleException(String message) Constructs a new ModuleException with the specified detail message.ModuleException(String message, Throwable cause) Constructs a new ModuleException with the specified detail message and cause.Constructs a new ModuleException with the specified detail message, cause, and metadata. -
Method Summary
Modifier and TypeMethodDescriptionaddMetadata(String key, Object value) Adds a metadata entry to this exception.Gets all metadata entries as an unmodifiable map.getMetadata(String key) Gets the value of a metadata entry.toString()Returns a string representation of this exception, including the message, cause, and metadata.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
Constructor Details
-
ModuleException
Constructs a new ModuleException with the specified detail message.- Parameters:
message- the detail message (which is saved for later retrieval by theThrowable.getMessage()method)
-
ModuleException
Constructs a new ModuleException with the specified detail message and cause.- Parameters:
message- the detail message (which is saved for later retrieval by theThrowable.getMessage()method)cause- the cause (which is saved for later retrieval by theThrowable.getCause()method). A null value is permitted, and indicates that the cause is nonexistent or unknown.
-
ModuleException
Constructs a new ModuleException with the specified detail message, cause, and metadata.- Parameters:
message- the detail message (which is saved for later retrieval by theThrowable.getMessage()method)cause- the cause (which is saved for later retrieval by theThrowable.getCause()method). A null value is permitted, and indicates that the cause is nonexistent or unknown.metadata- a map of additional context information about the exception
-
-
Method Details
-
addMetadata
Adds a metadata entry to this exception.- Parameters:
key- the key for the metadata entryvalue- the value for the metadata entry- Returns:
- this exception instance for method chaining
-
getMetadata
Gets the value of a metadata entry.- Parameters:
key- the key for the metadata entry- Returns:
- the value for the metadata entry, or null if the key doesn't exist
-
getMetadata
Gets all metadata entries as an unmodifiable map.- Returns:
- an unmodifiable view of the metadata map
-
toString
Returns a string representation of this exception, including the message, cause, and metadata.
-