public abstract class AcsJException
extends java.lang.Exception
ErrorTrace or
ACSException objects.
See AcsJException(ErrorTrace), getErrorTrace(), #getACSException.
Not to be confused with alma.ACSErr.ACSException,
which is a CORBA user exception with an alma.ACSErr.ErrorTrace inside.
ACSException is declared as final,
so that it's not an option to make our AcsJException
a subclass of it. (todo check if that's due to OMG spec or JacORB).
For the conversion to and from the CORBA exception types,
two ErrorTrace properties (i.e. NameValue objects
referenced from ErrorTrace#data) are added:
javaex.class to store the exception class for later reconstruction
javaex.msg to store the message text provided in the
various constructors of Throwable and subclasses.| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
m_file |
protected java.lang.String |
m_host |
protected int |
m_line |
protected java.lang.String |
m_method |
protected java.lang.String |
m_process |
protected java.util.Properties |
m_properties |
protected Severity |
m_severity |
protected java.lang.String |
m_sourceObject |
protected java.lang.String |
m_threadName |
protected long |
m_timeMilli |
| Constructor and Description |
|---|
AcsJException() |
AcsJException(ErrorTrace etCause) |
AcsJException(java.lang.String message) |
AcsJException(java.lang.String message,
ErrorTrace etCause)
Creates a new exception, with the chain of causing exceptions
derived from
etCause. |
AcsJException(java.lang.String message,
java.lang.Throwable cause)
Constructor from another exception, with a message.
|
| Modifier and Type | Method and Description |
|---|---|
protected ErrorTrace |
createSingleErrorTrace()
Creates an
ErrorTrace object that represents this exception. |
static ErrorTrace |
createSingleErrorTrace(java.lang.Throwable thr,
long defaultTimeMilli)
Converts a Throwable that may not be an AcsJException to an
ErrorTrace. |
protected abstract int |
getErrorCode()
Forces a subclass to choose an ACS error code.
|
ErrorTrace |
getErrorTrace()
Converts this exception (and all "caused-by" throwables it might have)
to an
ErrorTrace that links to
its caused-by ErrorTrace objects. |
protected abstract int |
getErrorType()
Forces a subclass to choose an ACS error type.
|
java.lang.String |
getFile() |
java.lang.String |
getHost() |
int |
getLine() |
java.lang.String |
getMethod() |
NameValue[] |
getNameValueArray()
To be used by
getErrorTrace() or whoever else
cares about a NameValue[]. |
java.lang.String |
getProcess() |
java.lang.String |
getProperty(java.lang.String key) |
Severity |
getSeverity()
Returns the Severity level currently associated with this exception instance.
|
java.lang.String |
getShortDescription()
Returns the short description which is a hardcoded text particular for a (type, code) combination.
|
java.lang.String |
getSourceObject() |
java.lang.String |
getThreadName() |
long |
getTimestampMillis()
Gets the timestamp when this exception was created.
|
int |
getTraceDepth()
Gets the total number of linked ("caused-by") exceptions including this one.
|
void |
log(java.util.logging.Logger logger)
Logs this exception and all causing exceptions.
|
static void |
setProcessName(java.lang.String name)
If we have some better name than "java", for example the unique name of
the java container.
|
java.lang.Object |
setProperty(java.lang.String key,
java.lang.String value)
Allows extra information to be attached to the exception.
|
void |
setSeverity()
Sets the default severity level to
Severity#Error. |
AcsJCompletion |
toAcsJCompletion()
Creates an AcsJCompletion that contains this exception.
|
abstract org.omg.CORBA.UserException |
toCorbaException()
Creates a CORBA
UserException from this exception. |
java.lang.String |
toString() |
protected java.lang.String m_host
protected java.lang.String m_process
protected int m_line
protected java.lang.String m_method
protected java.lang.String m_file
protected java.lang.String m_sourceObject
protected java.lang.String m_threadName
protected Severity m_severity
protected java.util.Properties m_properties
protected long m_timeMilli
public AcsJException()
public AcsJException(java.lang.String message)
public AcsJException(java.lang.String message,
java.lang.Throwable cause)
If cause is a CORBA exception generated by the ACS error system,
then its ErrorTrace is automatically converted to a chain of AcsJ-style exceptions.
cause - the causing exceptionCorbaExceptionConverter.convertHiddenErrorTrace(Throwable)public AcsJException(ErrorTrace etCause)
public AcsJException(java.lang.String message,
ErrorTrace etCause)
etCause.message - etCause - public java.lang.String toString()
toString in class java.lang.Throwablepublic static void setProcessName(java.lang.String name)
name - protected abstract int getErrorType()
protected abstract int getErrorCode()
public java.lang.String getShortDescription()
abstract because the exception class that corresponds to an error type
(but not an error code) would otherwise have to overload it with returning an empty string.public abstract org.omg.CORBA.UserException toCorbaException()
UserException from this exception.
Subclasses must return their associated UserException
with an ErrorTrace member.
By convention, subclasses must also implement another method that returns
the correct subtype of UserException.
No problem with a code generator of course...
public AcsJCompletion toAcsJCompletion()
AcsJCompletion.getAcsJException() will yield this exception.public void setSeverity()
Severity#Error.
May be overridden by a subclass to set the default severity for that exception,
or may be called from application code to set it for a specific exception instance.public Severity getSeverity()
public java.lang.Object setProperty(java.lang.String key,
java.lang.String value)
null if it did not have one.public java.lang.String getProperty(java.lang.String key)
public NameValue[] getNameValueArray()
getErrorTrace() or whoever else
cares about a NameValue[].public long getTimestampMillis()
public ErrorTrace getErrorTrace()
ErrorTrace that links to
its caused-by ErrorTrace objects.
To be used whenever the Corba wall is hit and the Java exception must be converted to an ACS-Corba-exception.
protected ErrorTrace createSingleErrorTrace()
ErrorTrace object that represents this exception.
Linked exceptions are not considered, so the returned ErrorTrace.previousError is left as null.public static ErrorTrace createSingleErrorTrace(java.lang.Throwable thr,
long defaultTimeMilli)
ErrorTrace.
For example, thr could be a NullPointerException thrown in the same process and thus not yet converted
to DefaultAcsJException, but wrapped by some subclass of AcsJException which contains the NPE as its cause.
defaultTimeMilli - Java-time (1970-based) used to estimate a time stamp if none is available,
in order to avoid something from October 1582 in the new ErrorTrace.
Typically the timestamp from the wrapping AcsJException.createSingleErrorTrace()public void log(java.util.logging.Logger logger)
logger - the JDK logger to be used for logging this exception.public int getTraceDepth()
Not to be confused with the length of Throwable.getStackTrace(), which
refers to the call stack for the current exception, and not to linked causing exception.
public java.lang.String getFile()
public java.lang.String getHost()
public int getLine()
public java.lang.String getMethod()
public java.lang.String getProcess()
public java.lang.String getThreadName()
public java.lang.String getSourceObject()