Class FileException

All Implemented Interfaces:
Serializable

public class FileException extends LocationException
This class implements a checked exception that is associated with the location of a file or directory.
See Also:
  • Constructor Details

    • FileException

      public FileException(String message, Path location, Object... replacements)
      Creates a new instance of an exception with the specified detail message and associated location.
      Parameters:
      message - the detail message of the exception.
      location - the location with which the exception will be associated, which may be null.
      replacements - the items whose string representations will replace placeholders in message.
    • FileException

      public FileException(String message, Throwable cause, Path location, Object... replacements)
      Creates a new instance of an exception with the specified detail message, cause and associated location.
      Parameters:
      message - the detail message of the exception.
      cause - the underlying cause of the exception.
      location - the location with which the exception will be associated, which may be null.
      replacements - the items whose string representations will replace placeholders in message.
    • FileException

      public FileException(BaseException exception, Path location, Object... replacements)
      Creates a new instance of an exception from the detail message and cause of the specified exception and the specified location.
      Parameters:
      exception - the exception that will provide the detail message and underlying cause.
      location - the location with which the exception will be associated, which may be null.
      replacements - the items whose string representations will replace placeholders in message.
  • Method Details

    • locationToString

      public static String locationToString(Path location)
      Returns a string representation of the specified location.
      Parameters:
      location - the location whose string representation is required, which may be null.
      Returns:
      a string representation of location.
    • createMessage

      public static String createMessage(String message, Path location, Object... replacements)
      Creates a composite message from the specified components, and returns the result.
      Parameters:
      message - the base message.
      location - the location that will be prefixed to message, which may be null.
      replacements - the items whose string representations will replace placeholders in message.
      Returns:
      a composite detail message created from message, location and replacements.
    • throwCause

      public static void throwCause(Throwable exception) throws FileException
      Tests the cause of the specified exception, and throws the causal exception if it is a FileException.
      Parameters:
      exception - the exception of interest.
      Throws:
      FileException - if the cause of exception is a FileException.
    • throwCause

      public static void throwCause(Throwable exception, boolean traverse) throws FileException
      Tests the cause of the specified exception, or, optionally, searches the causal chain of the specified exception, and, if a FileException is found, throws it.
      Parameters:
      exception - the exception of interest.
      traverse - if true, the causal chain of exception will be searched for a FileException; otherwise, only the immediate cause will be tested.
      Throws:
      FileException -
      • if traverse is false and the cause of exception is a FileException, or
      • if traverse is true and a FileException is found in the causal chain of exception.
    • getLocation

      public Path getLocation()
      Returns the location with which this exception is associated.
      Returns:
      the location with which this exception is associated.