Package uk.blankaspect.common.exception2
Class FileException
java.lang.Object
java.lang.Throwable
java.lang.Exception
uk.blankaspect.common.exception2.BaseException
uk.blankaspect.common.exception2.LocationException
uk.blankaspect.common.exception2.FileException
- All Implemented Interfaces:
Serializable
This class implements a checked exception that is associated with the location of a file or directory.
- See Also:
-
Field Summary
Fields inherited from class uk.blankaspect.common.exception2.BaseException
EMPTY
-
Constructor Summary
ConstructorsConstructorDescriptionFileException
(String message, Throwable cause, Path location, Object... replacements) Creates a new instance of an exception with the specified detail message, cause and associated location.FileException
(String message, Path location, Object... replacements) Creates a new instance of an exception with the specified detail message and associated location.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. -
Method Summary
Modifier and TypeMethodDescriptionstatic String
createMessage
(String message, Path location, Object... replacements) Creates a composite message from the specified components, and returns the result.Returns the location with which this exception is associated.static String
locationToString
(Path location) Returns a string representation of the specified location.static void
throwCause
(Throwable exception) Tests the cause of the specified exception, and throws the causal exception if it is aFileException
.static void
throwCause
(Throwable exception, boolean traverse) Tests the cause of the specified exception, or, optionally, searches the causal chain of the specified exception, and, if aFileException
is found, throws it.Methods inherited from class uk.blankaspect.common.exception2.LocationException
createMessage
Methods inherited from class uk.blankaspect.common.exception2.BaseException
createMessage
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
FileException
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 benull
.replacements
- the items whose string representations will replace placeholders inmessage
.
-
FileException
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 benull
.replacements
- the items whose string representations will replace placeholders inmessage
.
-
FileException
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 benull
.replacements
- the items whose string representations will replace placeholders inmessage
.
-
-
Method Details
-
locationToString
Returns a string representation of the specified location.- Parameters:
location
- the location whose string representation is required, which may benull
.- Returns:
- a string representation of
location
.
-
createMessage
Creates a composite message from the specified components, and returns the result.- Parameters:
message
- the base message.location
- the location that will be prefixed tomessage
, which may benull
.replacements
- the items whose string representations will replace placeholders inmessage
.- Returns:
- a composite detail message created from
message
,location
andreplacements
.
-
throwCause
Tests the cause of the specified exception, and throws the causal exception if it is aFileException
.- Parameters:
exception
- the exception of interest.- Throws:
FileException
- if the cause ofexception
is aFileException
.
-
throwCause
Tests the cause of the specified exception, or, optionally, searches the causal chain of the specified exception, and, if aFileException
is found, throws it.- Parameters:
exception
- the exception of interest.traverse
- iftrue
, the causal chain ofexception
will be searched for aFileException
; otherwise, only the immediate cause will be tested.- Throws:
FileException
-- if
traverse
isfalse
and the cause ofexception
is aFileException
, or - if
traverse
istrue
and aFileException
is found in the causal chain ofexception
.
- if
-
getLocation
Returns the location with which this exception is associated.- Returns:
- the location with which this exception is associated.
-