Class DataException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.northconcepts.datapipeline.core.DataException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ParseException
Indicates an error has occurred during the course of execution.
DataException retrofits RuntimeException with the ability to contain
properties and to prepend text to the message after construction.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new exception.DataException(String message) Constructs a new exception with the specified detail message.DataException(String message, Throwable cause) Constructs a new exception with the specified detail message and cause.DataException(Throwable cause) Constructs a new exception with the specified cause. -
Method Summary
Modifier and TypeMethodDescriptioncontributeExceptionProperties(DataExceptionContributor... contributors) Adds the properties of each non-null contributor to this exception and returns it.Returns the value mapped to the specified key ornull.booleangetAsBoolean(String name) Returns the value mapped to the specified key as abooleanor throwsNullPointeException.getAsDatetime(String name) Returns the value mapped to the specified key as aDateornull.doublegetAsDouble(String name) Returns the value mapped to the specified key as adoubleor throwsNullPointeException.intgetAsInteger(String name) Returns the value mapped to the specified key as anintor throwsNullPointeException.longReturns the value mapped to the specified key as alongor throwsNullPointeException.getAsString(String name) Returns the value mapped to the specified key as aStringornull.<T extends Throwable>
TgetExceptionFromCause(Class<T> causeClass) ReturnscauseClassif this exception was caused by (or one of its nested exceptions was caused by) the specified exception.Returns the field name associated with this exception.Returns the detail message string of this exception along with any prefixed text.Returns the detail message string of this exception along with any prefixed text and properties (name-value pairs).Returns the values associated with this exception as aMap.Returns the properties asname=[value]lines sorted by name, or null if there are none.Returns the record associated with this exception.Returns the root cause of this throwable orthisif the cause is nonexistent or unknown.booleanisCausedBy(Class<? extends Throwable> causeClass) Returnstrueif this exception was caused by (or one of its nested exceptions was caused by) the specified exception.booleanReturnstrueif the nested exception indicates that a thread was interrupted.prefixMessageWith(String message) Prefixes this exception's message with the specified text.voidPrints this throwable and its backtrace to the specified print stream.voidPrints this throwable and its backtrace to the specified print writer.Maps abooleanvalue to the specified key, overwriting any previous association.Maps a character value to the specified key, overwriting any previous association.Maps adoublevalue to the specified key, overwriting any previous association.Maps anintvalue to the specified key, overwriting any previous association.Maps alongvalue to the specified key, overwriting any previous association.Maps a value to the specified key, overwriting any previous association.set(String name, Collection<?> value) Maps a collection to the specified key, overwriting any previous association.Maps a java.util.Map to the specified key, overwriting any previous association.setFieldName(String fieldName) sets the field name associated with this exception.Sets the record associated with this exception.Returns the class name and message without the properties thattoString()appends.toString()static DataExceptionConverts an exception to aDataExceptionand prefixes the original message with the specified text.static DataExceptionConverts an exception to aDataException.static DataExceptionwrap(Throwable e, DataExceptionContributor... contributors) Wraps the exception aswrap(Throwable)does and adds the properties of each non-null contributor.static DataExceptionwrap(Throwable e, String namePrefix, DataExceptionContributor... contributors) Wraps the exception aswrap(Throwable)does and adds the properties of each non-null contributor, usingnamePrefixas the start of their keys.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, setStackTrace
-
Constructor Details
-
DataException
public DataException()Constructs a new exception. -
DataException
Constructs a new exception with the specified detail message. -
DataException
Constructs a new exception with the specified cause. -
DataException
Constructs a new exception with the specified detail message and cause.
-
-
Method Details
-
wrap
Converts an exception to aDataExceptionand prefixes the original message with the specified text. If the supplied exception is an instanceofDataException, it will be returned, otherwise it will be nested inside aDataException. In either case the result message will be prefixed with the supplied text.- Parameters:
message- the text to prefix to the original messageexception- the exception to convert- Returns:
- the converted exception
-
wrap
Converts an exception to aDataException. If the supplied exception is an instanceofDataException, it will be returned, otherwise it will be nested inside aDataException.- Parameters:
exception- the exception to convert- Returns:
- the converted exception
-
wrap
Wraps the exception aswrap(Throwable)does and adds the properties of each non-null contributor. -
wrap
public static DataException wrap(Throwable e, String namePrefix, DataExceptionContributor... contributors) Wraps the exception aswrap(Throwable)does and adds the properties of each non-null contributor, usingnamePrefixas the start of their keys. -
get
Returns the value mapped to the specified key ornull. -
getAsString
Returns the value mapped to the specified key as aStringornull. -
getAsInteger
Returns the value mapped to the specified key as anintor throwsNullPointeException. -
getAsLong
Returns the value mapped to the specified key as alongor throwsNullPointeException. -
getAsDouble
Returns the value mapped to the specified key as adoubleor throwsNullPointeException. -
getAsBoolean
Returns the value mapped to the specified key as abooleanor throwsNullPointeException. -
getAsDatetime
Returns the value mapped to the specified key as aDateornull. -
set
Maps a java.util.Map to the specified key, overwriting any previous association.- Parameters:
name- key with which the specified value is to be associated.value- value to be associated with the specified key.- Returns:
- this exception
-
set
Maps a collection to the specified key, overwriting any previous association.- Parameters:
name- key with which the specified value is to be associated.value- value to be associated with the specified key.- Returns:
- this exception
-
set
Maps a value to the specified key, overwriting any previous association.- Parameters:
name- key with which the specified value is to be associated.value- value to be associated with the specified key.- Returns:
- this exception
-
set
Maps a character value to the specified key, overwriting any previous association. If the character represents a special, non-printable value (end-of-file, new-line, carriage return, etc.), it will be converted to a human-readable string.- Parameters:
name- key with which the specified value is to be associated.value- value to be associated with the specified key.- Returns:
- this exception
-
set
Maps anintvalue to the specified key, overwriting any previous association.- Parameters:
name- key with which the specified value is to be associated.value- value to be associated with the specified key.- Returns:
- this exception
-
set
Maps alongvalue to the specified key, overwriting any previous association.- Parameters:
name- key with which the specified value is to be associated.value- value to be associated with the specified key.- Returns:
- this exception
-
set
Maps adoublevalue to the specified key, overwriting any previous association.- Parameters:
name- key with which the specified value is to be associated.value- value to be associated with the specified key.- Returns:
- this exception
-
set
Maps abooleanvalue to the specified key, overwriting any previous association.- Parameters:
name- key with which the specified value is to be associated.value- value to be associated with the specified key.- Returns:
- this exception
-
getFieldName
Returns the field name associated with this exception. -
setFieldName
sets the field name associated with this exception.- Returns:
- this exception
-
getRecord
Returns the record associated with this exception. -
setRecord
Sets the record associated with this exception.- Returns:
- this exception
-
getProperties
Returns the values associated with this exception as aMap.- Returns:
- a non-null array of value names.
- See Also:
-
getPropertiesAsString
Returns the properties asname=[value]lines sorted by name, or null if there are none. -
prefixMessageWith
Prefixes this exception's message with the specified text.- Parameters:
message- the text to prefix to the original message- Returns:
- this exception
-
getMessage
Returns the detail message string of this exception along with any prefixed text. This method is equivalent to callinggetOriginalMessageWithPrefix().- Overrides:
getMessagein classThrowable
-
getMessageWithProperties
Returns the detail message string of this exception along with any prefixed text and properties (name-value pairs). -
printStackTrace
Prints this throwable and its backtrace to the specified print stream.- Overrides:
printStackTracein classThrowable- Parameters:
s-PrintStreamto use for output
-
printStackTrace
Prints this throwable and its backtrace to the specified print writer.- Overrides:
printStackTracein classThrowable- Parameters:
s-PrintWriterto use for output
-
isCauseInterruptedException
public boolean isCauseInterruptedException()Returnstrueif the nested exception indicates that a thread was interrupted.- See Also:
-
isCausedBy
Returnstrueif this exception was caused by (or one of its nested exceptions was caused by) the specified exception. -
getExceptionFromCause
ReturnscauseClassif this exception was caused by (or one of its nested exceptions was caused by) the specified exception. -
getRootCause
Returns the root cause of this throwable orthisif the cause is nonexistent or unknown. -
toString
-
toOriginalString
Returns the class name and message without the properties thattoString()appends. -
contributeExceptionProperties
Adds the properties of each non-null contributor to this exception and returns it.
-