public class DataException extends RuntimeException
DataException
retrofits RuntimeException
with the ability to contain
properties and to prepend text to the message after construction.Constructor and Description |
---|
DataException()
Constructs 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.
|
Modifier and Type | Method and Description |
---|---|
DataException |
contributeExceptionProperties(DataExceptionContributor... contributors) |
Object |
get(String name)
Returns the value mapped to the specified key or
null . |
boolean |
getAsBoolean(String name)
Returns the value mapped to the specified key as a
boolean or throws NullPointeException . |
Date |
getAsDatetime(String name)
Returns the value mapped to the specified key as a
Date or null . |
double |
getAsDouble(String name)
Returns the value mapped to the specified key as a
double or throws NullPointeException . |
int |
getAsInteger(String name)
Returns the value mapped to the specified key as an
int or throws NullPointeException . |
long |
getAsLong(String name)
Returns the value mapped to the specified key as a
long or throws NullPointeException . |
String |
getAsString(String name)
Returns the value mapped to the specified key as a
String or null . |
<T extends Throwable> |
getExceptionFromCause(Class<T> causeClass)
Returns
causeClass if this exception was caused by (or one of its nested exceptions was caused by) the specified exception. |
String |
getFieldName()
Returns the field name associated with this exception.
|
String |
getMessage()
Returns the detail message string of this exception along with any prefixed text.
|
String |
getMessageWithProperties()
Returns the detail message string of this exception along with any prefixed text and properties (name-value pairs).
|
Map<String,Object> |
getProperties()
Returns the values associated with this exception as a
Map . |
String |
getPropertiesAsString() |
Record |
getRecord()
Returns the record associated with this exception.
|
Throwable |
getRootCause()
Returns the root cause of this throwable or
this if the
cause is nonexistent or unknown. |
boolean |
isCausedBy(Class<? extends Throwable> causeClass)
Returns
true if this exception was caused by (or one of its nested exceptions was caused by) the specified exception. |
boolean |
isCauseInterruptedException()
Returns
true if the nested exception indicates that a thread was interrupted. |
DataException |
prefixMessageWith(String message)
Prefixes this exception's message with the specified text.
|
void |
printStackTrace(PrintStream s)
Prints this throwable and its backtrace to the specified print stream.
|
void |
printStackTrace(PrintWriter s)
Prints this throwable and its backtrace to the specified
print writer.
|
DataException |
set(String name,
boolean value)
Maps a
boolean value to the specified key, overwriting any previous association. |
DataException |
set(String name,
char value)
Maps a character value to the specified key, overwriting any previous association.
|
DataException |
set(String name,
Collection<?> value)
Maps a collection to the specified key, overwriting any previous association.
|
DataException |
set(String name,
double value)
Maps a
double value to the specified key, overwriting any previous association. |
DataException |
set(String name,
int value)
Maps an
int value to the specified key, overwriting any previous association. |
DataException |
set(String name,
long value)
Maps a
long value to the specified key, overwriting any previous association. |
DataException |
set(String name,
Map<?,?> value)
Maps a java.util.Map to the specified key, overwriting any previous association.
|
DataException |
set(String name,
Object value)
Maps a value to the specified key, overwriting any previous association.
|
DataException |
setFieldName(String fieldName)
sets the field name associated with this exception.
|
DataException |
setRecord(Record record)
Sets the record associated with this exception.
|
String |
toOriginalString() |
String |
toString() |
static DataException |
wrap(String message,
Throwable exception)
Converts an exception to a
DataException and prefixes the original message with the specified text. |
static DataException |
wrap(Throwable exception)
Converts an exception to a
DataException . |
static DataException |
wrap(Throwable e,
DataExceptionContributor... contributors) |
static DataException |
wrap(Throwable e,
String namePrefix,
DataExceptionContributor... contributors) |
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, setStackTrace
public DataException()
public DataException(String message)
public DataException(Throwable cause)
public static DataException wrap(String message, Throwable exception)
DataException
and prefixes the original message with the specified text.
If the supplied exception is an instanceof DataException
, it will be returned, otherwise it will be
nested inside a DataException
. In either case the result message will be prefixed with the supplied text.message
- the text to prefix to the original messageexception
- the exception to convertpublic static DataException wrap(Throwable exception)
DataException
. If the supplied exception is an instanceof DataException
,
it will be returned, otherwise it will be nested inside a DataException
.exception
- the exception to convertpublic static DataException wrap(Throwable e, DataExceptionContributor... contributors)
public static DataException wrap(Throwable e, String namePrefix, DataExceptionContributor... contributors)
public String getAsString(String name)
String
or null
.public int getAsInteger(String name)
int
or throws NullPointeException
.public long getAsLong(String name)
long
or throws NullPointeException
.public double getAsDouble(String name)
double
or throws NullPointeException
.public boolean getAsBoolean(String name)
boolean
or throws NullPointeException
.public Date getAsDatetime(String name)
Date
or null
.public DataException set(String name, Map<?,?> value)
name
- key with which the specified value is to be associated.value
- value to be associated with the specified key.public DataException set(String name, Collection<?> value)
name
- key with which the specified value is to be associated.value
- value to be associated with the specified key.public DataException set(String name, Object value)
name
- key with which the specified value is to be associated.value
- value to be associated with the specified key.public DataException set(String name, char value)
name
- key with which the specified value is to be associated.value
- value to be associated with the specified key.public DataException set(String name, int value)
int
value to the specified key, overwriting any previous association.name
- key with which the specified value is to be associated.value
- value to be associated with the specified key.public DataException set(String name, long value)
long
value to the specified key, overwriting any previous association.name
- key with which the specified value is to be associated.value
- value to be associated with the specified key.public DataException set(String name, double value)
double
value to the specified key, overwriting any previous association.name
- key with which the specified value is to be associated.value
- value to be associated with the specified key.public DataException set(String name, boolean value)
boolean
value to the specified key, overwriting any previous association.name
- key with which the specified value is to be associated.value
- value to be associated with the specified key.public String getFieldName()
public DataException setFieldName(String fieldName)
public Record getRecord()
public DataException setRecord(Record record)
public Map<String,Object> getProperties()
Map
.set(String, Object)
,
get(String)
public String getPropertiesAsString()
public DataException prefixMessageWith(String message)
message
- the text to prefix to the original messagepublic String getMessage()
getOriginalMessageWithPrefix()
.getMessage
in class Throwable
public String getMessageWithProperties()
public void printStackTrace(PrintStream s)
printStackTrace
in class Throwable
s
- PrintStream
to use for outputpublic void printStackTrace(PrintWriter s)
printStackTrace
in class Throwable
s
- PrintWriter
to use for outputpublic boolean isCauseInterruptedException()
true
if the nested exception indicates that a thread was interrupted.public boolean isCausedBy(Class<? extends Throwable> causeClass)
true
if this exception was caused by (or one of its nested exceptions was caused by) the specified exception.public <T extends Throwable> T getExceptionFromCause(Class<T> causeClass)
causeClass
if this exception was caused by (or one of its nested exceptions was caused by) the specified exception.public Throwable getRootCause()
this
if the
cause is nonexistent or unknown.public String toOriginalString()
public DataException contributeExceptionProperties(DataExceptionContributor... contributors)
Copyright (c) 2006-2024 North Concepts Inc. All Rights Reserved.