|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.jostraca.util.StandardException
com.ricebridge.xmlman.in.XmlManagerBaseException
com.ricebridge.xmlman.XmlManagerException
Xml Manager has a single Exception type for indicating errors.
XmlManagerException is a RuntimeException. This choice is deliberate as
it makes the API more user-friendly (less to think about) and more maintainable (easier to extend).
If you wish to catch XmlManagerExceptions at source instead of higher up
the call stack, you can use:
try {
List data = xmlManager.load( "mydata.xml", recordSpec );
}
catch( XmlManagerException xme ) {
System.out.println( xme );
}
XmlManagerExceptions produce human readable error messages if you call getUserMessage()
or toString(). Calls to getMessage will return a more technical description of the error.
Loading and saving of XML data can made fault tolerant. By default, an XmlManagerException is thrown
as soon as an error occurs and processing halts. If you want to continue loading or saving data records, set
XmlSpec.setIgnoreBadRecords(boolean) to true. In this case, errors are stored until the operation is complete
and can be retrieved with XmlManager.getBadRecords(). The errors are described using the BadRecord object.
Statistics on total bad records can be obtained from Stats.getTotalBadRecords().
One very important point: according to the XML specification,
XML parsers must halt when an XML syntax error occurs. This means that XML syntax errors always causes XML Manager
to halt processing and throw
an XmlManagerException. It also means that no data can be obtained from the record containing the error
and no BadRecord object can be created.
XmlManagerExceptions have error codes to allow automated handling. The full list is given in
MsgCode. The human readable text for each message is given
in the message.properties file.
Here is an example of using the error codes:
...
catch( XmlManagerException xme ) {
if( XmlManagerException.CODE_internal_error == xme.getCode() ) {
log( xme.getMessage() );
}
else {
System.out.println( xme.getUserMessage() );
}
}
When an error occurs due to a problem with a data record, you can use the hasBadRecord() and
getBadRecord() methods to access the BadRecord object describing the data record that caused the
problem. Please note that this information may be incomplete depending on the nature of the error.
Sometimes an XmlManagerException is caused by an underlying problem deeper in the system.
In this case, you can access the contained Exception by using
the getContained() method.
The XML Manager component makes use of code from the open source template engine
Jostraca.
For further documentation concerning the super classes of XmlManagerException,
see StandardException.
| Nested Class Summary |
| Nested classes inherited from class com.ricebridge.xmlman.in.XmlManagerBaseException |
XmlManagerBaseException.Code |
| Nested classes inherited from class org.jostraca.util.StandardException |
StandardException.Cat |
| Field Summary |
| Fields inherited from class org.jostraca.util.StandardException |
CODE_user, DEFAULT_CODE, iCode, iContained, iContext, iOrigin, iOriginalMessage, KEY_standard |
| Constructor Summary | |
XmlManagerException()
An empty XmlManagerException. |
|
XmlManagerException(Throwable pContained)
Specify the error code. |
|
XmlManagerException(XmlManagerBaseException.Code pCode)
Specify the error code. |
|
XmlManagerException(XmlManagerBaseException.Code pCode,
BadRecord pBadRecord)
Specify the error code, and the BadRecord. |
|
XmlManagerException(XmlManagerBaseException.Code pCode,
BadRecord pBadRecord,
Throwable pContained)
Specify the error code, the BadRecord that caused the error, and the Exception that occurred. |
|
XmlManagerException(XmlManagerBaseException.Code pCode,
Object pContext)
Specify the error code, and the error context. |
|
XmlManagerException(XmlManagerBaseException.Code pCode,
String pText)
Specify the error code, and the error message text. |
|
XmlManagerException(XmlManagerBaseException.Code pCode,
String[] pContext)
Specify the error code, and provide a set of replacement values for the user-friendly error message associated with this code. |
|
XmlManagerException(XmlManagerBaseException.Code pCode,
String[] pContext,
Throwable pContained)
Specify the error code, provide a set of replacement values for the user-friendly error message associated with this code, and the original Exception that caused the error. |
|
XmlManagerException(XmlManagerBaseException.Code pCode,
String pText,
Throwable pContained)
Specify the error code, the error message test, and the original Exception that caused the error. |
|
XmlManagerException(XmlManagerBaseException.Code pCode,
Throwable pContained)
Specify the error code, and the original Exception that caused the error. |
|
| Method Summary | |
BadRecord |
getBadRecord()
Return the BadRecord that caused this XmlManagerException, if any. |
String |
getUserMessage()
Return a user-friendly error message describing the problem. |
UserMessageFormatter |
getUserMessageFormatter()
Get the UserMessageFormatter object that formats user-friendly
error messages. |
protected static PropertySet |
handleBadRecord(BadRecord pBadRecord)
Capture the details of a BadRecord object and convert them into replacement strings for use in user-friendly
error messages. |
boolean |
hasBadRecord()
Check if this XmlManagerException was caused by a BadRecord. |
String |
toString()
Return a user-friendly error message describing the problem. |
| Methods inherited from class org.jostraca.util.StandardException |
formatContextValues, formatContextValues, formatContextValues, getCat, getCode, getContained, getContainedStandard, getContext, getContextValues, getContextValues, getKey, getOriginalMessage, hasContained, makeStackTrace |
| Methods inherited from class java.lang.Throwable |
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public XmlManagerException()
XmlManagerException.
public XmlManagerException(XmlManagerBaseException.Code pCode)
pCode - XmlManagerBaseException.Code object
public XmlManagerException(XmlManagerBaseException.Code pCode,
BadRecord pBadRecord)
BadRecord.
pCode - XmlManagerBaseException.Code objectpBadRecord - BadRecord that caused the error
public XmlManagerException(XmlManagerBaseException.Code pCode,
Object pContext)
pCode - XmlManagerBaseException.Code objectpContext - user-defined object describing error context
public XmlManagerException(XmlManagerBaseException.Code pCode,
String pText)
pCode - XmlManagerBaseException.Code objectpText - error message text
public XmlManagerException(XmlManagerBaseException.Code pCode,
String pText,
Throwable pContained)
Exception that caused the error.
pCode - XmlManagerBaseException.Code objectpText - error message textpContained - Exception that caused the error
public XmlManagerException(XmlManagerBaseException.Code pCode,
String[] pContext)
pCode - XmlManagerBaseException.Code objectpContext - error message values
public XmlManagerException(XmlManagerBaseException.Code pCode,
Throwable pContained)
Exception that caused the error.
pCode - XmlManagerBaseException.Code objectpContained - Exception that caused the error
public XmlManagerException(XmlManagerBaseException.Code pCode,
String[] pContext,
Throwable pContained)
Exception that caused the error.
pCode - XmlManagerBaseException.Code objectpContext - error message valuespContained - Exception that caused the error
public XmlManagerException(XmlManagerBaseException.Code pCode,
BadRecord pBadRecord,
Throwable pContained)
BadRecord that caused the error, and the Exception that occurred.
pCode - XmlManagerBaseException.Code objectpBadRecord - BadRecord that caused the errorpContained - Exception that caused the errorpublic XmlManagerException(Throwable pContained)
pContained - Exception that caused the error| Method Detail |
public boolean hasBadRecord()
XmlManagerException was caused by a BadRecord.
getBadRecord()public BadRecord getBadRecord()
BadRecord that caused this XmlManagerException, if any.
Note: may return an empty BadRecord with no data.
hasBadRecord()public String toString()
getUserMessage()public String getUserMessage()
Note that the standard getMessage method returns a
technical description of the error more suitable for debugging.
public UserMessageFormatter getUserMessageFormatter()
UserMessageFormatter object that formats user-friendly
error messages.
protected static PropertySet handleBadRecord(BadRecord pBadRecord)
BadRecord object and convert them into replacement strings for use in user-friendly
error messages.
pBadRecord - BadRecord to analyse.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||