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

public class ModuleException extends Exception
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 Details

    • ModuleException

      public ModuleException(String message)
      Constructs a new ModuleException with the specified detail message.
      Parameters:
      message - the detail message (which is saved for later retrieval by the Throwable.getMessage() method)
    • ModuleException

      public ModuleException(String message, Throwable cause)
      Constructs a new ModuleException with the specified detail message and cause.
      Parameters:
      message - the detail message (which is saved for later retrieval by the Throwable.getMessage() method)
      cause - the cause (which is saved for later retrieval by the Throwable.getCause() method). A null value is permitted, and indicates that the cause is nonexistent or unknown.
    • ModuleException

      public ModuleException(String message, Throwable cause, Map<String,Object> metadata)
      Constructs a new ModuleException with the specified detail message, cause, and metadata.
      Parameters:
      message - the detail message (which is saved for later retrieval by the Throwable.getMessage() method)
      cause - the cause (which is saved for later retrieval by the Throwable.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

      public ModuleException addMetadata(String key, Object value)
      Adds a metadata entry to this exception.
      Parameters:
      key - the key for the metadata entry
      value - the value for the metadata entry
      Returns:
      this exception instance for method chaining
    • getMetadata

      public Object getMetadata(String key)
      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

      public Map<String,Object> getMetadata()
      Gets all metadata entries as an unmodifiable map.
      Returns:
      an unmodifiable view of the metadata map
    • toString

      public String toString()
      Returns a string representation of this exception, including the message, cause, and metadata.
      Overrides:
      toString in class Throwable
      Returns:
      a string representation of this exception