db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/util ExceptionHelper.java
Date Sat, 22 Oct 2005 12:20:15 GMT
arminw      2005/10/22 05:20:15

  Modified:    src/java/org/apache/ojb/broker/util ExceptionHelper.java
  Log:
  minor improvement, always log root stack trace
  
  Revision  Changes    Path
  1.2       +27 -15    db-ojb/src/java/org/apache/ojb/broker/util/ExceptionHelper.java
  
  Index: ExceptionHelper.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/ExceptionHelper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ExceptionHelper.java	1 Oct 2005 13:48:50 -0000	1.1
  +++ ExceptionHelper.java	22 Oct 2005 12:20:15 -0000	1.2
  @@ -63,25 +63,26 @@
           */
           String eol = SystemUtils.LINE_SEPARATOR;
           StringBuffer msg = new StringBuffer(eol);
  +        eol += "* ";
   
           if(ex instanceof BatchUpdateException)
           {
               BatchUpdateException tmp = (BatchUpdateException) ex;
  -            msg.append("BatchUpdateException during execution.");
  +            msg.append("* BatchUpdateException during execution of sql-statement:");
               msg.append(eol).append("Batch update count is '").append(tmp.getUpdateCounts()).append("'");
           }
           else if(ex instanceof SQLWarning)
           {
  -            msg.append("SQLWarning during execution.");
  +            msg.append("* SQLWarning during execution of sql-statement:");
           }
           else
           {
  -            msg.append("SQLException during execution.");
  +            msg.append("* SQLException during execution of sql-statement:");
           }
   
           if(sql != null)
           {
  -            msg.append(eol).append("sql statement was '").append(sql).append("'.");
  +            msg.append(eol).append("sql statement was '").append(sql).append("'");
           }
           msg.append(eol).append("Exception message is [").append(ex.getMessage()).append("]");
           msg.append(eol).append("Vendor error code [").append(ex.getErrorCode()).append("]");
  @@ -101,7 +102,7 @@
           {
               msg.append(eol).append("Target class is '")
                       .append(cld.getClassNameOfObject())
  -                    .append("'.");
  +                    .append("'");
               FieldDescriptor[] fields = cld.getPkFields();
               msg.append(eol).append("PK of the target object is [");
               for(int i = 0; i < fields.length; i++)
  @@ -118,9 +119,10 @@
                   }
                   catch(Exception ignore)
                   {
  +                    msg.append(" PK field build FAILED! ");
                   }
               }
  -            msg.append("].");
  +            msg.append("]");
           }
           if(values != null)
           {
  @@ -134,22 +136,32 @@
                   msg.append("]");
               }
           }
  -        if(obj != null) msg.append(eol).append("Source object: ").append(obj);
  +        if(obj != null)
  +        {
  +            msg.append(eol).append("Source object: ");
  +            try
  +            {
  +                msg.append(obj.toString());
  +            }
  +            catch(Exception e)
  +            {
  +                msg.append(obj.getClass());
  +            }
  +        }
   
           // message string for PB exception
           String shortMsg = msg.toString();
   
           // add causing stack trace
           Throwable rootCause = ExceptionUtils.getRootCause(ex);
  -        if(rootCause  != null)
  -        {
  -            msg.append(eol).append("The root cause stack is: ");
  -            String rootStack = ExceptionUtils.getStackTrace(rootCause);
  -            msg.append(eol).append(rootStack);
  -        }
  +        if(rootCause == null) rootCause = ex;
  +        msg.append(eol).append("The root stack trace is --> ");
  +        String rootStack = ExceptionUtils.getStackTrace(rootCause);
  +        msg.append(eol).append(rootStack);
  +        msg.append(SystemUtils.LINE_SEPARATOR).append("**");
   
           // log error message
  -        if(logger != null) logger.error(msg.toString(), ex);
  +        if(logger != null) logger.error(msg.toString());
   
           // throw a specific type of runtime exception for a key constraint.
           if("23000".equals(stateCode) || "23505".equals(stateCode))
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message