You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Robert Pepersack <rp...@mdinsurance.state.md.us> on 2004/04/16 15:31:42 UTC

Logger Wrapper That Translates SQLException

Hi all.

Has anyone written a Logger wrapper whose error() methods return a 
Throwable?  I have a class that translates SQLExceptions into more generic 
exceptions, all of which extend a base exception class (e.g. 
StoredProcedureNotFoundException extends DataAccessException).  I would 
like to have one class do my logging, exception translation, and have it 
return the new exception.  This would be cleaner than performing all of 
these steps in my catch blocks, as in:

catch (SQLException e)
{
             DataAccessException dae =
                     translator.translate("QueryJdbcFacade.executeQuery()",
                                          null,
                                          e);
             logger.error("Throwing exception: " +
                          dae.toString() +
                          "...",
                          dae);
             throw dae;
}

It would be even nicer if I could use the wrapper in concert with an object 
renderer to create my own custom message format.

Thanks,

Bob Pepersack


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org