public class DatabaseException extends ApplicationException
DatabaseException
can be caught by application code
(for example a unique key constraint).
Example:
... catch (DatabaseException e) { if (e.getErrorType.equals(DatabaseException.UNIQUE_CONSTRAINT)) { String recName = e.getRecordName(); ... } }
Modifier and Type | Class and Description |
---|---|
static class |
DatabaseException.ErrorType
Inner class representing error types
|
Modifier and Type | Field and Description |
---|---|
static DatabaseException.ErrorType |
INSTANCE_NOT_FOUND
Thrown when the entity "Get" operation fails (when no instance is available).
|
static DatabaseException.ErrorType |
NULL_VALUE_CONSTRAINT
Thrown when trying to insert/update null in a column with a NOT NULL constraint.
|
static DatabaseException.ErrorType |
TABLE_DOES_NOT_EXIST
Thrown when a table or view does not exist.
|
static DatabaseException.ErrorType |
UNIQUE_CONSTRAINT
Thrown when a unique constraint exception is thrown from database.
|
APPLICATION_ERROR, DATABASE_ERROR, ENCRYPTION_ERROR, error, LICENSE_VIOLATION_ERROR, MANUAL_DECISION, NOT_LOGGED_ON_ERROR, PARSE_ERROR, SECURITY_ERROR, SYSTEM_ERROR, TIMEOUT_ERROR, UNKNOWN, USER_ABORT, VALIDATION_ERROR
Constructor and Description |
---|
DatabaseException(DatabaseException.ErrorType errorType,
FndTranslatableText msg)
Create a new instance of DatabaseException.
|
DatabaseException(DatabaseException.ErrorType errorType,
FndTranslatableText msg,
java.lang.String recordName)
Create a new instance of DatabaseException.
|
DatabaseException(DatabaseException.ErrorType errorType,
java.lang.String msg)
Create a new instance of DatabaseException.
|
DatabaseException(DatabaseException.ErrorType errorType,
java.lang.String msg,
java.lang.String recordName)
Create a new instance of DatabaseException.
|
Modifier and Type | Method and Description |
---|---|
DatabaseException.ErrorType |
getErrorType()
Return the type of error.
|
java.lang.String |
getExtraInfo()
Get the detailed SQL error
|
java.lang.String |
getRecordName()
If this exception was thrown in the context of a entity save method,
this method will return the name of the record being saved when the exception was
thrown (if available).
|
boolean |
hasRecordName()
Check if the record name has been set on this exception.
|
void |
setExtraInfo(java.lang.String info)
Set the detailed SQL error
|
void |
setRecordName(java.lang.String recordName)
Set the name of the offending record.
|
error, getMessage, getTranslationID, getType, runtimeError
public static final DatabaseException.ErrorType UNIQUE_CONSTRAINT
public static final DatabaseException.ErrorType NULL_VALUE_CONSTRAINT
public static final DatabaseException.ErrorType INSTANCE_NOT_FOUND
public static final DatabaseException.ErrorType TABLE_DOES_NOT_EXIST
public DatabaseException(DatabaseException.ErrorType errorType, FndTranslatableText msg, java.lang.String recordName)
errorType
- Type of error. (Must never be null!)msg
- Original database error message.recordName
- Name of the record causing this exception.public DatabaseException(DatabaseException.ErrorType errorType, FndTranslatableText msg)
errorType
- Type of error. (Must never be null!)msg
- Original database error message.public DatabaseException(DatabaseException.ErrorType errorType, java.lang.String msg, java.lang.String recordName)
errorType
- Type of error. (Must never be null!)msg
- Original database error message.recordName
- Name of the record causing this exception.public DatabaseException(DatabaseException.ErrorType errorType, java.lang.String msg)
errorType
- Type of error. (Must never be null!)msg
- Original database error message.public void setRecordName(java.lang.String recordName)
recordName
- Name of the record.public java.lang.String getRecordName()
public boolean hasRecordName()
public DatabaseException.ErrorType getErrorType()
public java.lang.String getExtraInfo()
getExtraInfo
in class IfsException
public void setExtraInfo(java.lang.String info)
info
- String containing detailed SQL error