com.ricebridge.xmlman
Class XmlManagerException

java.lang.Object
  extended byjava.lang.Throwable
      extended byjava.lang.Exception
          extended byjava.lang.RuntimeException
              extended byorg.jostraca.util.StandardException
                  extended bycom.ricebridge.xmlman.in.XmlManagerBaseException
                      extended bycom.ricebridge.xmlman.XmlManagerException
All Implemented Interfaces:
Serializable

public class XmlManagerException
extends XmlManagerBaseException

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.

See Also:
Serialized Form

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 com.ricebridge.xmlman.in.XmlManagerBaseException
CODE_bad_encoding, CODE_bad_func_prefix, CODE_bad_insource, CODE_bad_instream, CODE_bad_record, CODE_bad_record_outpath, CODE_bad_record_path, CODE_bad_uricontent, CODE_bad_xml_file, CODE_bad_xml_string, CODE_badnum_fieldnames, CODE_badrecordlistener_exception, CODE_baos_close, CODE_cce_getdata, CODE_cce_list_record, CODE_cce_stringenc, CODE_close_exception, CODE_empty_prefix, CODE_file_cant_read, CODE_file_cant_write, CODE_file_not_exist, CODE_filter_expr, CODE_folder_denied, CODE_general, CODE_getbadrecs, CODE_getbeanfield, CODE_getbeanfield_msg, CODE_handlebadrecord_exception, CODE_handlerecord_exception, CODE_internal_exception, CODE_make_context, CODE_multiple, CODE_new_rl, CODE_new_rp, CODE_new_saxpf, CODE_new_xmlwrtr, CODE_newbean, CODE_no_fieldnames, CODE_no_reclis, CODE_no_record_path, CODE_no_recordspec, CODE_ns_empty_prefix, CODE_ns_empty_uri, CODE_null_record, CODE_osw_flush, CODE_osw_write, CODE_recordlistener_exception, CODE_recordlistener_set, CODE_recordprovider_exception, CODE_recordprovider_set, CODE_resultset_method, CODE_resultset_reset, CODE_rs_null, CODE_rsmd_method, CODE_run_badmethod, CODE_runonpath, CODE_saxparser_config, CODE_setbeanfield, CODE_setbeanfield_msg, CODE_setfeature, CODE_stats_method, CODE_system, CODE_target_start, CODE_unknown_column, CODE_unknown_dc_expr, CODE_unknown_func, CODE_unsup_axis, CODE_unsup_func, CODE_var_empty_name, CODE_xpath_err, CODE_xpath_syntax
 
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 com.ricebridge.xmlman.in.XmlManagerBaseException
CODE_bad_encoding, CODE_bad_encoding, CODE_bad_encoding, CODE_bad_encoding, CODE_bad_encoding, CODE_bad_encoding, CODE_bad_func_prefix, CODE_bad_func_prefix, CODE_bad_func_prefix, CODE_bad_func_prefix, CODE_bad_func_prefix, CODE_bad_func_prefix, CODE_bad_insource, CODE_bad_insource, CODE_bad_insource, CODE_bad_insource, CODE_bad_insource, CODE_bad_insource, CODE_bad_instream, CODE_bad_instream, CODE_bad_instream, CODE_bad_instream, CODE_bad_instream, CODE_bad_instream, CODE_bad_record_outpath, CODE_bad_record_outpath, CODE_bad_record_outpath, CODE_bad_record_outpath, CODE_bad_record_outpath, CODE_bad_record_outpath, CODE_bad_record_path, CODE_bad_record_path, CODE_bad_record_path, CODE_bad_record_path, CODE_bad_record_path, CODE_bad_record_path, CODE_bad_record, CODE_bad_record, CODE_bad_record, CODE_bad_record, CODE_bad_record, CODE_bad_record, CODE_bad_uricontent, CODE_bad_uricontent, CODE_bad_uricontent, CODE_bad_uricontent, CODE_bad_uricontent, CODE_bad_uricontent, CODE_bad_xml_file, CODE_bad_xml_file, CODE_bad_xml_file, CODE_bad_xml_file, CODE_bad_xml_file, CODE_bad_xml_file, CODE_bad_xml_string, CODE_bad_xml_string, CODE_bad_xml_string, CODE_bad_xml_string, CODE_bad_xml_string, CODE_bad_xml_string, CODE_badnum_fieldnames, CODE_badnum_fieldnames, CODE_badnum_fieldnames, CODE_badnum_fieldnames, CODE_badnum_fieldnames, CODE_badnum_fieldnames, CODE_badrecordlistener_exception, CODE_badrecordlistener_exception, CODE_badrecordlistener_exception, CODE_badrecordlistener_exception, CODE_badrecordlistener_exception, CODE_badrecordlistener_exception, CODE_baos_close, CODE_baos_close, CODE_baos_close, CODE_baos_close, CODE_baos_close, CODE_baos_close, CODE_cce_getdata, CODE_cce_getdata, CODE_cce_getdata, CODE_cce_getdata, CODE_cce_getdata, CODE_cce_getdata, CODE_cce_list_record, CODE_cce_list_record, CODE_cce_list_record, CODE_cce_list_record, CODE_cce_list_record, CODE_cce_list_record, CODE_cce_stringenc, CODE_cce_stringenc, CODE_cce_stringenc, CODE_cce_stringenc, CODE_cce_stringenc, CODE_cce_stringenc, CODE_close_exception, CODE_close_exception, CODE_close_exception, CODE_close_exception, CODE_close_exception, CODE_close_exception, CODE_empty_prefix, CODE_empty_prefix, CODE_empty_prefix, CODE_empty_prefix, CODE_empty_prefix, CODE_empty_prefix, CODE_file_cant_read, CODE_file_cant_read, CODE_file_cant_read, CODE_file_cant_read, CODE_file_cant_read, CODE_file_cant_read, CODE_file_cant_write, CODE_file_cant_write, CODE_file_cant_write, CODE_file_cant_write, CODE_file_cant_write, CODE_file_cant_write, CODE_file_not_exist, CODE_file_not_exist, CODE_file_not_exist, CODE_file_not_exist, CODE_file_not_exist, CODE_file_not_exist, CODE_filter_expr, CODE_filter_expr, CODE_filter_expr, CODE_filter_expr, CODE_filter_expr, CODE_filter_expr, CODE_folder_denied, CODE_folder_denied, CODE_folder_denied, CODE_folder_denied, CODE_folder_denied, CODE_folder_denied, CODE_general, CODE_general, CODE_general, CODE_general, CODE_general, CODE_general, CODE_getbadrecs, CODE_getbadrecs, CODE_getbadrecs, CODE_getbadrecs, CODE_getbadrecs, CODE_getbadrecs, CODE_getbeanfield_msg, CODE_getbeanfield_msg, CODE_getbeanfield_msg, CODE_getbeanfield_msg, CODE_getbeanfield_msg, CODE_getbeanfield_msg, CODE_getbeanfield, CODE_getbeanfield, CODE_getbeanfield, CODE_getbeanfield, CODE_getbeanfield, CODE_getbeanfield, CODE_handlebadrecord_exception, CODE_handlebadrecord_exception, CODE_handlebadrecord_exception, CODE_handlebadrecord_exception, CODE_handlebadrecord_exception, CODE_handlebadrecord_exception, CODE_handlerecord_exception, CODE_handlerecord_exception, CODE_handlerecord_exception, CODE_handlerecord_exception, CODE_handlerecord_exception, CODE_handlerecord_exception, CODE_internal_exception, CODE_internal_exception, CODE_internal_exception, CODE_internal_exception, CODE_internal_exception, CODE_internal_exception, CODE_make_context, CODE_make_context, CODE_make_context, CODE_make_context, CODE_make_context, CODE_make_context, CODE_multiple, CODE_multiple, CODE_multiple, CODE_multiple, CODE_multiple, CODE_multiple, CODE_new_rl, CODE_new_rl, CODE_new_rl, CODE_new_rl, CODE_new_rl, CODE_new_rl, CODE_new_rp, CODE_new_rp, CODE_new_rp, CODE_new_rp, CODE_new_rp, CODE_new_rp, CODE_new_saxpf, CODE_new_saxpf, CODE_new_saxpf, CODE_new_saxpf, CODE_new_saxpf, CODE_new_saxpf, CODE_new_xmlwrtr, CODE_new_xmlwrtr, CODE_new_xmlwrtr, CODE_new_xmlwrtr, CODE_new_xmlwrtr, CODE_new_xmlwrtr, CODE_newbean, CODE_newbean, CODE_newbean, CODE_newbean, CODE_newbean, CODE_newbean, CODE_no_fieldnames, CODE_no_fieldnames, CODE_no_fieldnames, CODE_no_fieldnames, CODE_no_fieldnames, CODE_no_fieldnames, CODE_no_reclis, CODE_no_reclis, CODE_no_reclis, CODE_no_reclis, CODE_no_reclis, CODE_no_reclis, CODE_no_record_path, CODE_no_record_path, CODE_no_record_path, CODE_no_record_path, CODE_no_record_path, CODE_no_record_path, CODE_no_recordspec, CODE_no_recordspec, CODE_no_recordspec, CODE_no_recordspec, CODE_no_recordspec, CODE_no_recordspec, CODE_ns_empty_prefix, CODE_ns_empty_prefix, CODE_ns_empty_prefix, CODE_ns_empty_prefix, CODE_ns_empty_prefix, CODE_ns_empty_prefix, CODE_ns_empty_uri, CODE_ns_empty_uri, CODE_ns_empty_uri, CODE_ns_empty_uri, CODE_ns_empty_uri, CODE_ns_empty_uri, CODE_null_record, CODE_null_record, CODE_null_record, CODE_null_record, CODE_null_record, CODE_null_record, CODE_osw_flush, CODE_osw_flush, CODE_osw_flush, CODE_osw_flush, CODE_osw_flush, CODE_osw_flush, CODE_osw_write, CODE_osw_write, CODE_osw_write, CODE_osw_write, CODE_osw_write, CODE_osw_write, CODE_recordlistener_exception, CODE_recordlistener_exception, CODE_recordlistener_exception, CODE_recordlistener_exception, CODE_recordlistener_exception, CODE_recordlistener_exception, CODE_recordlistener_set, CODE_recordlistener_set, CODE_recordlistener_set, CODE_recordlistener_set, CODE_recordlistener_set, CODE_recordlistener_set, CODE_recordprovider_exception, CODE_recordprovider_exception, CODE_recordprovider_exception, CODE_recordprovider_exception, CODE_recordprovider_exception, CODE_recordprovider_exception, CODE_recordprovider_set, CODE_recordprovider_set, CODE_recordprovider_set, CODE_recordprovider_set, CODE_recordprovider_set, CODE_recordprovider_set, CODE_resultset_method, CODE_resultset_method, CODE_resultset_method, CODE_resultset_method, CODE_resultset_method, CODE_resultset_method, CODE_resultset_reset, CODE_resultset_reset, CODE_resultset_reset, CODE_resultset_reset, CODE_resultset_reset, CODE_resultset_reset, CODE_rs_null, CODE_rs_null, CODE_rs_null, CODE_rs_null, CODE_rs_null, CODE_rs_null, CODE_rsmd_method, CODE_rsmd_method, CODE_rsmd_method, CODE_rsmd_method, CODE_rsmd_method, CODE_rsmd_method, CODE_run_badmethod, CODE_run_badmethod, CODE_run_badmethod, CODE_run_badmethod, CODE_run_badmethod, CODE_run_badmethod, CODE_runonpath, CODE_runonpath, CODE_runonpath, CODE_runonpath, CODE_runonpath, CODE_runonpath, CODE_saxparser_config, CODE_saxparser_config, CODE_saxparser_config, CODE_saxparser_config, CODE_saxparser_config, CODE_saxparser_config, CODE_setbeanfield_msg, CODE_setbeanfield_msg, CODE_setbeanfield_msg, CODE_setbeanfield_msg, CODE_setbeanfield_msg, CODE_setbeanfield_msg, CODE_setbeanfield, CODE_setbeanfield, CODE_setbeanfield, CODE_setbeanfield, CODE_setbeanfield, CODE_setbeanfield, CODE_setfeature, CODE_setfeature, CODE_setfeature, CODE_setfeature, CODE_setfeature, CODE_setfeature, CODE_stats_method, CODE_stats_method, CODE_stats_method, CODE_stats_method, CODE_stats_method, CODE_stats_method, CODE_system, CODE_system, CODE_system, CODE_system, CODE_system, CODE_system, CODE_target_start, CODE_target_start, CODE_target_start, CODE_target_start, CODE_target_start, CODE_target_start, CODE_unknown_column, CODE_unknown_column, CODE_unknown_column, CODE_unknown_column, CODE_unknown_column, CODE_unknown_column, CODE_unknown_dc_expr, CODE_unknown_dc_expr, CODE_unknown_dc_expr, CODE_unknown_dc_expr, CODE_unknown_dc_expr, CODE_unknown_dc_expr, CODE_unknown_func, CODE_unknown_func, CODE_unknown_func, CODE_unknown_func, CODE_unknown_func, CODE_unknown_func, CODE_unsup_axis, CODE_unsup_axis, CODE_unsup_axis, CODE_unsup_axis, CODE_unsup_axis, CODE_unsup_axis, CODE_unsup_func, CODE_unsup_func, CODE_unsup_func, CODE_unsup_func, CODE_unsup_func, CODE_unsup_func, CODE_var_empty_name, CODE_var_empty_name, CODE_var_empty_name, CODE_var_empty_name, CODE_var_empty_name, CODE_var_empty_name, CODE_xpath_err, CODE_xpath_err, CODE_xpath_err, CODE_xpath_err, CODE_xpath_err, CODE_xpath_err, CODE_xpath_syntax, CODE_xpath_syntax, CODE_xpath_syntax, CODE_xpath_syntax, CODE_xpath_syntax, CODE_xpath_syntax, getPackage
 
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

XmlManagerException

public XmlManagerException()
An empty XmlManagerException.


XmlManagerException

public XmlManagerException(XmlManagerBaseException.Code pCode)
Specify the error code.

Parameters:
pCode - XmlManagerBaseException.Code object

XmlManagerException

public XmlManagerException(XmlManagerBaseException.Code pCode,
                           BadRecord pBadRecord)
Specify the error code, and the BadRecord.

Parameters:
pCode - XmlManagerBaseException.Code object
pBadRecord - BadRecord that caused the error

XmlManagerException

public XmlManagerException(XmlManagerBaseException.Code pCode,
                           Object pContext)
Specify the error code, and the error context.

Parameters:
pCode - XmlManagerBaseException.Code object
pContext - user-defined object describing error context

XmlManagerException

public XmlManagerException(XmlManagerBaseException.Code pCode,
                           String pText)
Specify the error code, and the error message text.

Parameters:
pCode - XmlManagerBaseException.Code object
pText - error message text

XmlManagerException

public XmlManagerException(XmlManagerBaseException.Code pCode,
                           String pText,
                           Throwable pContained)
Specify the error code, the error message test, and the original Exception that caused the error.

Parameters:
pCode - XmlManagerBaseException.Code object
pText - error message text
pContained - Exception that caused the error

XmlManagerException

public 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.

Parameters:
pCode - XmlManagerBaseException.Code object
pContext - error message values

XmlManagerException

public XmlManagerException(XmlManagerBaseException.Code pCode,
                           Throwable pContained)
Specify the error code, and the original Exception that caused the error.

Parameters:
pCode - XmlManagerBaseException.Code object
pContained - Exception that caused the error

XmlManagerException

public 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.

Parameters:
pCode - XmlManagerBaseException.Code object
pContext - error message values
pContained - Exception that caused the error

XmlManagerException

public XmlManagerException(XmlManagerBaseException.Code pCode,
                           BadRecord pBadRecord,
                           Throwable pContained)
Specify the error code, the BadRecord that caused the error, and the Exception that occurred.

Parameters:
pCode - XmlManagerBaseException.Code object
pBadRecord - BadRecord that caused the error
pContained - Exception that caused the error

XmlManagerException

public XmlManagerException(Throwable pContained)
Specify the error code.

Parameters:
pContained - Exception that caused the error
Method Detail

hasBadRecord

public boolean hasBadRecord()
Check if this XmlManagerException was caused by a BadRecord.

See Also:
getBadRecord()

getBadRecord

public BadRecord getBadRecord()
Return the BadRecord that caused this XmlManagerException, if any.

Note: may return an empty BadRecord with no data.

See Also:
hasBadRecord()

toString

public String toString()
Return a user-friendly error message describing the problem.

See Also:
getUserMessage()

getUserMessage

public String getUserMessage()
Return a user-friendly error message describing the problem.

Note that the standard getMessage method returns a technical description of the error more suitable for debugging.


getUserMessageFormatter

public UserMessageFormatter getUserMessageFormatter()
Get the UserMessageFormatter object that formats user-friendly error messages.


handleBadRecord

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.

Parameters:
pBadRecord - BadRecord to analyse.


Copyright © 2004-2005 Ricebridge