public class StandardException
extends java.lang.Exception
This class is abstract to ensure that an implementation only throws a specific exception (e.g. TransactionException) which is a sub-class
A method in an iterface in a protocol under com.ibm.db2j.protocol.Database must only throw a StandardException (if it needs to throw an exception). This indicates that the method can throw an exception and therefore its caller must ensure that any resources it allocates will be cleaned up in the event of an exception in the StandardException hierarchy.
Implementations of methods that throw StandardException can have throws clause that are more specific than StandardException.
Modifier and Type | Class and Description |
---|---|
static class |
StandardException.BadMessageArgumentException
Dummy exception to catch incorrect use of
StandardException.newException(), at compile-time.
|
Modifier and Type | Field and Description |
---|---|
private java.lang.Object[] |
arguments |
private boolean |
isForPublicAPI |
private java.sql.SQLException |
next |
private int |
report |
static int |
REPORT_ALWAYS |
static int |
REPORT_DEFAULT |
static int |
REPORT_NEVER |
private int |
severity |
private java.lang.String |
sqlState |
private java.lang.String |
textMessage |
Modifier | Constructor and Description |
---|---|
protected |
StandardException(java.lang.String messageID) |
private |
StandardException(java.lang.String sqlState,
java.lang.String text)
This constructor is used when we already have the
message text.
|
protected |
StandardException(java.lang.String messageID,
java.lang.Throwable t,
java.lang.Object[] args) |
Modifier and Type | Method and Description |
---|---|
static StandardException |
closeException()
A special exception to close a session.
|
static StandardException |
getArgumentFerry(java.sql.SQLException se)
Unpack the exception, looking for a StandardException, which carries
the Derby messageID and arguments.
|
java.lang.Object[] |
getArguments() |
int |
getErrorCode() |
java.lang.String |
getErrorProperty(java.lang.String type)
Get the error code for an error given a type.
|
private static java.lang.String |
getErrorProperty(java.lang.String messageId,
java.lang.String type) |
java.lang.String |
getMessage()
The message stored in the super class Throwable must be set
up object creation.
|
java.lang.String |
getMessageId()
Return the message identifier that is used to look up the
error message text in the messages.properties file.
|
java.sql.SQLException |
getNextException()
Get the next
SQLException that should be put into the parent
exception when this instance is converted to an SQLException . |
int |
getSeverity() |
static int |
getSeverityFromIdentifier(java.lang.String messageID)
Get the severity given a message identifier from org.apache.derby.iapi.reference.SQLState.
|
java.lang.String |
getSQLState()
Return the 5 character SQL State.
|
static java.lang.String |
getSQLStateFromIdentifier(java.lang.String messageID)
Convert a message identifer from org.apache.derby.iapi.reference.SQLState to
a SQLState five character string.
|
static StandardException |
interrupt(java.lang.InterruptedException ie) |
boolean |
isLockTimeout()
Is this a lock timeout exception.
|
boolean |
isLockTimeoutOrDeadlock()
Is this a lock timeout or lock deadlock exception.
|
boolean |
isSelfDeadlock()
Is this a self-deadlock exception caused by a nested transaction
being blocked by its parent's locks.
|
private static boolean |
isVacuousWrapper(java.lang.Throwable t)
Check if the top-level throwable is just a vacuous wrapper that does
not carry any useful information except what's returned by the
Throwable.getCause() method. |
(package private) void |
markAsPublicAPI()
Mark this exception as one that is thrown by a public API method.
|
static StandardException |
newException(java.lang.String messageId,
java.lang.Object... args) |
static StandardException |
newException(java.lang.String messageID,
java.lang.Object a1,
java.lang.Object a2,
java.lang.Throwable t)
Dummy overload which should never be called.
|
static StandardException |
newException(java.lang.String messageID,
java.lang.Object a1,
java.lang.Throwable t)
Dummy overload which should never be called.
|
static StandardException |
newException(java.lang.String messageId,
java.lang.Throwable t,
java.lang.Object... args) |
static StandardException |
newPreLocalizedException(java.lang.String MessageID,
java.lang.Throwable t,
java.lang.String localizedMessage)
Creates a new StandardException using message text that has already been localized.
|
static java.sql.SQLWarning |
newWarning(java.lang.String messageId,
java.lang.Object... oa) |
static StandardException |
normalClose() |
static StandardException |
plainWrapException(java.lang.Throwable t)
Similar to unexpectedUserException but makes no assumtion about
when the execption is being called.
|
int |
report()
Yes, report me.
|
void |
setReport(int report)
Set my report type.
|
void |
setSeverity(int severity) |
java.lang.String |
toString()
Don't print the class name in the toString() method.
|
static StandardException |
unexpectedUserException(java.lang.Throwable t) |
public static final int REPORT_DEFAULT
public static final int REPORT_NEVER
public static final int REPORT_ALWAYS
private transient java.lang.Object[] arguments
private int severity
private java.lang.String textMessage
private java.lang.String sqlState
private transient int report
private transient boolean isForPublicAPI
private transient java.sql.SQLException next
protected StandardException(java.lang.String messageID)
protected StandardException(java.lang.String messageID, java.lang.Throwable t, java.lang.Object[] args)
private StandardException(java.lang.String sqlState, java.lang.String text)
sqlState
- the sql state of the messagetext
- the text of the messagepublic final java.lang.Object[] getArguments()
public final int report()
public final void setReport(int report)
public final void setSeverity(int severity)
public final int getSeverity()
public final int getErrorCode()
public final java.lang.String getSQLState()
public final java.sql.SQLException getNextException()
SQLException
that should be put into the parent
exception when this instance is converted to an SQLException
.final void markAsPublicAPI()
PublicAPI
public static java.lang.String getSQLStateFromIdentifier(java.lang.String messageID)
messageID
- - the sql state id of the message from Derbypublic static int getSeverityFromIdentifier(java.lang.String messageID)
public static StandardException normalClose()
public static StandardException newException(java.lang.String messageId, java.lang.Object... args)
public static StandardException newException(java.lang.String messageId, java.lang.Throwable t, java.lang.Object... args)
public static StandardException newException(java.lang.String messageID, java.lang.Object a1, java.lang.Throwable t) throws StandardException.BadMessageArgumentException
messageID
- - the sql state id of the messagea1
- - Message argt
- - Incorrectly placed exception to be nestedStandardException.BadMessageArgumentException
- - always (dummy)public static StandardException newException(java.lang.String messageID, java.lang.Object a1, java.lang.Object a2, java.lang.Throwable t) throws StandardException.BadMessageArgumentException
messageID
- - the sql state id of the messagea1
- - First message arga2
- - Second message argt
- - Incorrectly placed exception to be nestedStandardException.BadMessageArgumentException
- - always (dummy)public static StandardException newPreLocalizedException(java.lang.String MessageID, java.lang.Throwable t, java.lang.String localizedMessage)
MessageID
- The SQLState and severity are derived from the ID. However the text message is not.t
- The Throwable that caused this exception, null if this exception was not caused by another Throwable.localizedMessage
- The message associated with this exception.
It is the caller's responsibility to ensure that this message is properly localized.
See org.apache.derby.iapi.tools.i18n.LocalizedResourcepublic static StandardException getArgumentFerry(java.sql.SQLException se)
SQLExceptionFactory
,
Util
private static boolean isVacuousWrapper(java.lang.Throwable t)
Throwable.getCause()
method.t
- the throwable to checktrue
if the throwable is a vacuous wrapper and the
only useful piece of information is the cause, or false
otherwisepublic static StandardException unexpectedUserException(java.lang.Throwable t)
public static StandardException plainWrapException(java.lang.Throwable t)
public static StandardException closeException()
public java.lang.String getMessage()
Thus the message stored by Throwable and obtained by the getMessage() of Throwable (ie. super.getMessage() in this class) is the message identifier. The actual text message is stored in this class at the first request.
getMessage
in class java.lang.Throwable
public final java.lang.String getMessageId()
public java.lang.String getErrorProperty(java.lang.String type)
public java.lang.String toString()
toString
in class java.lang.Throwable
private static java.lang.String getErrorProperty(java.lang.String messageId, java.lang.String type)
public static StandardException interrupt(java.lang.InterruptedException ie)
public static java.sql.SQLWarning newWarning(java.lang.String messageId, java.lang.Object... oa)
public final boolean isLockTimeout()
public final boolean isSelfDeadlock()
public final boolean isLockTimeoutOrDeadlock()
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.