[MOBY-guts] biomoby commit

Martin Senger senger at pub.open-bio.org
Sat Nov 12 16:43:48 UTC 2005


senger
Sat Nov 12 11:43:48 EST 2005
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared
In directory pub.open-bio.org:/tmp/cvs-serv12988/src/main/org/biomoby/shared

Modified Files:
	MobyException.java 
Log Message:


moby-live/Java/src/main/org/biomoby/shared MobyException.java,1.2,1.3
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyException.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyException.java	2005/04/20 21:42:09	1.2
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyException.java	2005/11/12 16:43:48	1.3
@@ -1,28 +1,34 @@
 // MobyException.java
 //
-//    senger at ebi.ac.uk
-//    February 2003
+// Created: February 2003
+//
+// This file is a component of the BioMoby project.
+// Copyright Martin Senger (martin.senger at gmail.com).
+//
 
 package org.biomoby.shared;
 
+import java.io.StringWriter;
+import java.io.PrintWriter;
+
 /** A general exception which can be used as a wrapper
  *  around other exceptions. Using this exception
  *  simplifies the code (but on the other hand it makes it less
  *  "type-safe" - which is usually not a problem when dealing
  *  with exceptions).
  *  <P>
- * @author <A HREF="mailto:senger at ebi.ac.uk">Martin Senger</A>
+ * @author <A HREF="mailto:martin.senger at gmail.com">Martin Senger</A>
  * @version $Id$
  */
 
 public class MobyException extends Exception {
 
+    private static org.apache.commons.logging.Log log =
+       org.apache.commons.logging.LogFactory.getLog (MobyException.class);
     
     private static final long serialVersionUID = 3257853190165969203L;
-    /** @serial
-     */
-    private Throwable theOriginalException = null;
 
+    /** @serial */
     public MobyException ()         { super(); }
 
     /******************************************************************************
@@ -36,22 +42,36 @@
      * It allows access to the original (wrapped) exception and its message.
      *
      * @param s message (or reason of)
-     * @param theOriginalException
+     * @param e original cause of this exception
      ******************************************************************************/
-    public MobyException (String s, Throwable theOriginalException) {
-	super (s);
-        this.theOriginalException = theOriginalException;
+    public MobyException (String s, Throwable e) {
+	super (s, e);
+	if (e != null) {
+	    boolean seriousError =
+		( (e instanceof java.lang.NullPointerException)   ||
+		  (e instanceof java.lang.ClassCastException)     ||
+		  (e instanceof java.lang.ClassNotFoundException) );
+	    if (seriousError || log.isDebugEnabled()) {
+		StringWriter sw = new StringWriter (500);
+		e.printStackTrace (new PrintWriter (sw));
+		if (seriousError)
+		    log.error (sw.toString());
+		else
+		    log.debug (sw.toString());
+	    }
+	}
     }
 
     /******************************************************************************
      * Retrieve the original exception. 
      *
+     * @deprecated Use instead <tt>getCause()</tt> directly.
+     *
      * @return an original exception which was wrapped by this BiomonyException, or
      *         null if there was no original exception involved
      ******************************************************************************/
     public Throwable getOriginalException() {
-        return theOriginalException;
+	return getCause();
     }
 
 }
-




More information about the MOBY-guts mailing list