com.ricebridge.csvman
Class CsvManagerException

java.lang.Object
  extended byjava.lang.Throwable
      extended byjava.lang.Exception
          extended byjava.lang.RuntimeException
              extended byorg.jostraca.util.StandardException
                  extended bycom.ricebridge.csvman.CsvManagerBaseException
                      extended bycom.ricebridge.csvman.CsvManagerException
All Implemented Interfaces:
Serializable

public class CsvManagerException
extends CsvManagerBaseException

CSV Manager has a single Exception type for indicating errors.

CsvManagerException 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). In addition, if you wish to catch CsvManagerExceptions at source instead of higher up the call stack, you can still do so:

    try {
      List data = csvManager.load( "mydata.csv");
    }
    catch( CsvManagerException ce ) {
      System.out.println( ce );
    }
  

CsvManagerExceptions produce human readable error messages if you call getUserMessage() or toString(). Calls to Throwable.getMessage() will return a more technical description of the error.

Loading and saving of CSV data can made more fault tolerant. By default, a CsvManagerException is thrown as soon as an error occurs and processing halts. If you want to continue loading or saving data lines, set CsvManager.setIgnoreBadLines(boolean) to true. In this case, errors are stored until the operation is complete and can be retrieved with CsvManager.getBadLines().

CsvManagerExceptions have error codes to allow automated handling. The full list is given in MsgCode. The human readable text for each message is given here: message.properties. Here is an example of using the error codes:

    ...
    catch( CsvManagerException ce ) {
      if( CsvManagerException.CODE_bad_line == ce.getCode() ) {
        System.out.println( "BAD LINE: "+ce );
      } else { throw ce; }
    }
  

If you implement your own LineListener you may need to throw Exceptions when errors occur. To do this you should use the code CODE_general like so:

    ...
    catch( Exception e ) {
      throw new CsvManagerException( CsvManagerException.CODE_general, "message", e );
    }
  
You can access the contained Exception using getContained()

Note that when CSV Manager reports a problem in a custom LineListener or LineProvider that was caused by an Exception inside the custom object, then you can also get hold of this exception using the getContained method. This is useful if you want to get a stack trace of this contained Exception.

The Ricebridge CSV Manager component makes use of code from the open source template engine Jostraca. For further documentation concerning the super classes of CsvManagerException, see StandardException.

Note: you cannot use the .CODE_* shortcuts with CsvManagerException as they return only CsvManagerBaseExceptions.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class com.ricebridge.csvman.CsvManagerBaseException
CsvManagerBaseException.Code
 
Nested classes inherited from class org.jostraca.util.StandardException
StandardException.Cat
 
Field Summary
 
Fields inherited from class com.ricebridge.csvman.CsvManagerBaseException
CODE_bad_dfmaxlen, CODE_bad_encoding, CODE_bad_end_line, CODE_bad_file, CODE_bad_line, CODE_bad_num_lines, CODE_bad_sink, CODE_bad_source, CODE_bad_start_line, CODE_cce_list_line, CODE_close_reader, CODE_close_writer, CODE_csvrs_new, CODE_csvtm_new, CODE_dfmaxlen, CODE_empty_char_string, CODE_emptyfieldname, CODE_escape_is_quote, CODE_escape_is_sep, CODE_escmap_key_not_char, CODE_escmap_value_not_char, CODE_field_endload, CODE_fieldlistener_exception, CODE_file_cant_read, CODE_file_cant_write, CODE_file_not_exist, CODE_file_not_found, CODE_general, CODE_getbadlines_notlist, CODE_getbeanfield, CODE_getbeanfield_msg, CODE_geterrmsgs_notlist, CODE_internal_exception, CODE_line_endload, CODE_line_errmsgs, CODE_linelistener_exception, CODE_lineprovider_exception, CODE_lineprovider_set, CODE_new_ll, CODE_new_lp, CODE_newbean, CODE_no_input_source, CODE_no_output_sink, CODE_nofieldnames, CODE_null_line, CODE_null_list_line, CODE_parse_error, CODE_parse_warning, CODE_quote_is_escape, CODE_quote_is_sep, CODE_rejected_line, CODE_resultset_getmetadata, CODE_resultset_getobject, CODE_resultset_next, CODE_rsmd_getcolcount, CODE_rsmd_getcolname, CODE_save_failed, CODE_setbeanfield, CODE_setbeanfield_msg, CODE_system, CODE_unknown_column
 
Fields inherited from class org.jostraca.util.StandardException
CODE_user, DEFAULT_CODE, iCode, iContained, iContext, iOrigin, iOriginalMessage, KEY_standard
 
Constructor Summary
CsvManagerException(CsvManagerBaseException.Code pCode)
           
CsvManagerException(CsvManagerBaseException.Code pCode, BadLine pBadLine)
           
CsvManagerException(CsvManagerBaseException.Code pCode, BadLine pBadLine, Throwable pContained)
           
CsvManagerException(CsvManagerBaseException.Code pCode, Object pContext)
           
CsvManagerException(CsvManagerBaseException.Code pCode, String pText)
           
CsvManagerException(CsvManagerBaseException.Code pCode, String[] pContext)
           
CsvManagerException(CsvManagerBaseException.Code pCode, String[] pContext, Throwable pContained)
           
CsvManagerException(CsvManagerBaseException.Code pCode, String pText, Throwable pContained)
           
CsvManagerException(CsvManagerBaseException.Code pCode, Throwable pContained)
           
CsvManagerException(Throwable pContained)
           
 
Method Summary
 BadLine getBadLine()
          may return empty BadLine if none set
 String getUserMessage()
           
protected static PropertySet handleBadLine(BadLine pBadLine)
           
protected static void handleBadLine(BadLine pBadLine, PropertySet pPropertySet)
           
 boolean hasBadLine()
           
protected  void setBadLine(BadLine pBadLine)
           
 String toString()
           
 
Methods inherited from class com.ricebridge.csvman.CsvManagerBaseException
CODE_bad_dfmaxlen, CODE_bad_dfmaxlen, CODE_bad_dfmaxlen, CODE_bad_dfmaxlen, CODE_bad_dfmaxlen, CODE_bad_dfmaxlen, CODE_bad_encoding, CODE_bad_encoding, CODE_bad_encoding, CODE_bad_encoding, CODE_bad_encoding, CODE_bad_encoding, CODE_bad_end_line, CODE_bad_end_line, CODE_bad_end_line, CODE_bad_end_line, CODE_bad_end_line, CODE_bad_end_line, CODE_bad_file, CODE_bad_file, CODE_bad_file, CODE_bad_file, CODE_bad_file, CODE_bad_file, CODE_bad_line, CODE_bad_line, CODE_bad_line, CODE_bad_line, CODE_bad_line, CODE_bad_line, CODE_bad_num_lines, CODE_bad_num_lines, CODE_bad_num_lines, CODE_bad_num_lines, CODE_bad_num_lines, CODE_bad_num_lines, CODE_bad_sink, CODE_bad_sink, CODE_bad_sink, CODE_bad_sink, CODE_bad_sink, CODE_bad_sink, CODE_bad_source, CODE_bad_source, CODE_bad_source, CODE_bad_source, CODE_bad_source, CODE_bad_source, CODE_bad_start_line, CODE_bad_start_line, CODE_bad_start_line, CODE_bad_start_line, CODE_bad_start_line, CODE_bad_start_line, CODE_cce_list_line, CODE_cce_list_line, CODE_cce_list_line, CODE_cce_list_line, CODE_cce_list_line, CODE_cce_list_line, CODE_close_reader, CODE_close_reader, CODE_close_reader, CODE_close_reader, CODE_close_reader, CODE_close_reader, CODE_close_writer, CODE_close_writer, CODE_close_writer, CODE_close_writer, CODE_close_writer, CODE_close_writer, CODE_csvrs_new, CODE_csvrs_new, CODE_csvrs_new, CODE_csvrs_new, CODE_csvrs_new, CODE_csvrs_new, CODE_csvtm_new, CODE_csvtm_new, CODE_csvtm_new, CODE_csvtm_new, CODE_csvtm_new, CODE_csvtm_new, CODE_dfmaxlen, CODE_dfmaxlen, CODE_dfmaxlen, CODE_dfmaxlen, CODE_dfmaxlen, CODE_dfmaxlen, CODE_empty_char_string, CODE_empty_char_string, CODE_empty_char_string, CODE_empty_char_string, CODE_empty_char_string, CODE_empty_char_string, CODE_emptyfieldname, CODE_emptyfieldname, CODE_emptyfieldname, CODE_emptyfieldname, CODE_emptyfieldname, CODE_emptyfieldname, CODE_escape_is_quote, CODE_escape_is_quote, CODE_escape_is_quote, CODE_escape_is_quote, CODE_escape_is_quote, CODE_escape_is_quote, CODE_escape_is_sep, CODE_escape_is_sep, CODE_escape_is_sep, CODE_escape_is_sep, CODE_escape_is_sep, CODE_escape_is_sep, CODE_escmap_key_not_char, CODE_escmap_key_not_char, CODE_escmap_key_not_char, CODE_escmap_key_not_char, CODE_escmap_key_not_char, CODE_escmap_key_not_char, CODE_escmap_value_not_char, CODE_escmap_value_not_char, CODE_escmap_value_not_char, CODE_escmap_value_not_char, CODE_escmap_value_not_char, CODE_escmap_value_not_char, CODE_field_endload, CODE_field_endload, CODE_field_endload, CODE_field_endload, CODE_field_endload, CODE_field_endload, CODE_fieldlistener_exception, CODE_fieldlistener_exception, CODE_fieldlistener_exception, CODE_fieldlistener_exception, CODE_fieldlistener_exception, CODE_fieldlistener_exception, 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_file_not_found, CODE_file_not_found, CODE_file_not_found, CODE_file_not_found, CODE_file_not_found, CODE_file_not_found, CODE_general, CODE_general, CODE_general, CODE_general, CODE_general, CODE_general, CODE_getbadlines_notlist, CODE_getbadlines_notlist, CODE_getbadlines_notlist, CODE_getbadlines_notlist, CODE_getbadlines_notlist, CODE_getbadlines_notlist, 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_geterrmsgs_notlist, CODE_geterrmsgs_notlist, CODE_geterrmsgs_notlist, CODE_geterrmsgs_notlist, CODE_geterrmsgs_notlist, CODE_geterrmsgs_notlist, CODE_internal_exception, CODE_internal_exception, CODE_internal_exception, CODE_internal_exception, CODE_internal_exception, CODE_internal_exception, CODE_line_endload, CODE_line_endload, CODE_line_endload, CODE_line_endload, CODE_line_endload, CODE_line_endload, CODE_line_errmsgs, CODE_line_errmsgs, CODE_line_errmsgs, CODE_line_errmsgs, CODE_line_errmsgs, CODE_line_errmsgs, CODE_linelistener_exception, CODE_linelistener_exception, CODE_linelistener_exception, CODE_linelistener_exception, CODE_linelistener_exception, CODE_linelistener_exception, CODE_lineprovider_exception, CODE_lineprovider_exception, CODE_lineprovider_exception, CODE_lineprovider_exception, CODE_lineprovider_exception, CODE_lineprovider_exception, CODE_lineprovider_set, CODE_lineprovider_set, CODE_lineprovider_set, CODE_lineprovider_set, CODE_lineprovider_set, CODE_lineprovider_set, CODE_new_ll, CODE_new_ll, CODE_new_ll, CODE_new_ll, CODE_new_ll, CODE_new_ll, CODE_new_lp, CODE_new_lp, CODE_new_lp, CODE_new_lp, CODE_new_lp, CODE_new_lp, CODE_newbean, CODE_newbean, CODE_newbean, CODE_newbean, CODE_newbean, CODE_newbean, CODE_no_input_source, CODE_no_input_source, CODE_no_input_source, CODE_no_input_source, CODE_no_input_source, CODE_no_input_source, CODE_no_output_sink, CODE_no_output_sink, CODE_no_output_sink, CODE_no_output_sink, CODE_no_output_sink, CODE_no_output_sink, CODE_nofieldnames, CODE_nofieldnames, CODE_nofieldnames, CODE_nofieldnames, CODE_nofieldnames, CODE_nofieldnames, CODE_null_line, CODE_null_line, CODE_null_line, CODE_null_line, CODE_null_line, CODE_null_line, CODE_null_list_line, CODE_null_list_line, CODE_null_list_line, CODE_null_list_line, CODE_null_list_line, CODE_null_list_line, CODE_parse_error, CODE_parse_error, CODE_parse_error, CODE_parse_error, CODE_parse_error, CODE_parse_error, CODE_parse_warning, CODE_parse_warning, CODE_parse_warning, CODE_parse_warning, CODE_parse_warning, CODE_parse_warning, CODE_quote_is_escape, CODE_quote_is_escape, CODE_quote_is_escape, CODE_quote_is_escape, CODE_quote_is_escape, CODE_quote_is_escape, CODE_quote_is_sep, CODE_quote_is_sep, CODE_quote_is_sep, CODE_quote_is_sep, CODE_quote_is_sep, CODE_quote_is_sep, CODE_rejected_line, CODE_rejected_line, CODE_rejected_line, CODE_rejected_line, CODE_rejected_line, CODE_rejected_line, CODE_resultset_getmetadata, CODE_resultset_getmetadata, CODE_resultset_getmetadata, CODE_resultset_getmetadata, CODE_resultset_getmetadata, CODE_resultset_getmetadata, CODE_resultset_getobject, CODE_resultset_getobject, CODE_resultset_getobject, CODE_resultset_getobject, CODE_resultset_getobject, CODE_resultset_getobject, CODE_resultset_next, CODE_resultset_next, CODE_resultset_next, CODE_resultset_next, CODE_resultset_next, CODE_resultset_next, CODE_rsmd_getcolcount, CODE_rsmd_getcolcount, CODE_rsmd_getcolcount, CODE_rsmd_getcolcount, CODE_rsmd_getcolcount, CODE_rsmd_getcolcount, CODE_rsmd_getcolname, CODE_rsmd_getcolname, CODE_rsmd_getcolname, CODE_rsmd_getcolname, CODE_rsmd_getcolname, CODE_rsmd_getcolname, CODE_save_failed, CODE_save_failed, CODE_save_failed, CODE_save_failed, CODE_save_failed, CODE_save_failed, 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_system, CODE_system, CODE_system, CODE_system, CODE_system, CODE_system, CODE_unknown_column, CODE_unknown_column, CODE_unknown_column, CODE_unknown_column, CODE_unknown_column, CODE_unknown_column, 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

CsvManagerException

public CsvManagerException(CsvManagerBaseException.Code pCode)

CsvManagerException

public CsvManagerException(CsvManagerBaseException.Code pCode,
                           BadLine pBadLine)

CsvManagerException

public CsvManagerException(CsvManagerBaseException.Code pCode,
                           Object pContext)

CsvManagerException

public CsvManagerException(CsvManagerBaseException.Code pCode,
                           String pText)

CsvManagerException

public CsvManagerException(CsvManagerBaseException.Code pCode,
                           String pText,
                           Throwable pContained)

CsvManagerException

public CsvManagerException(CsvManagerBaseException.Code pCode,
                           String[] pContext)

CsvManagerException

public CsvManagerException(CsvManagerBaseException.Code pCode,
                           Throwable pContained)

CsvManagerException

public CsvManagerException(CsvManagerBaseException.Code pCode,
                           String[] pContext,
                           Throwable pContained)

CsvManagerException

public CsvManagerException(CsvManagerBaseException.Code pCode,
                           BadLine pBadLine,
                           Throwable pContained)

CsvManagerException

public CsvManagerException(Throwable pContained)
Method Detail

hasBadLine

public boolean hasBadLine()

getBadLine

public BadLine getBadLine()
may return empty BadLine if none set


toString

public String toString()

getUserMessage

public String getUserMessage()

setBadLine

protected void setBadLine(BadLine pBadLine)

handleBadLine

protected static PropertySet handleBadLine(BadLine pBadLine)

handleBadLine

protected static void handleBadLine(BadLine pBadLine,
                                    PropertySet pPropertySet)


Copyright © 2003-2006 Ricebridge