1 24 package javax.jcr; 25 26 import java.io.PrintStream ; 27 import java.io.PrintWriter ; 28 29 35 public class RepositoryException extends Exception { 36 37 40 protected Exception rootException; 41 42 45 public RepositoryException() { 46 super(); 47 } 48 49 55 public RepositoryException(String s) { 56 super(s); 57 } 58 59 66 public RepositoryException(String s, Exception e) { 67 super(s); 68 69 70 if (e instanceof RepositoryException) { 71 RepositoryException e2 = (RepositoryException) e; 72 rootException = e2.rootException; 73 } else { 74 rootException = e; 75 } 76 } 77 78 83 public RepositoryException(Exception e) { 84 this(null, e); 85 } 86 87 92 public String getMessage() { 93 String s = super.getMessage(); 94 if (rootException == null) { 95 return s; 96 } else { 97 String s2 = rootException.getMessage(); 98 return s == null ? s2 : s + ": " + s2; 99 } 100 } 101 102 107 public Exception getRootException() { 108 return rootException; 109 } 110 111 115 public void printStackTrace() { 116 synchronized (System.err) { 117 super.printStackTrace(); 118 if (rootException != null) { 119 rootException.printStackTrace(); 120 } 121 } 122 } 123 124 130 public void printStackTrace(PrintStream s) { 131 synchronized (s) { 132 super.printStackTrace(s); 133 if (rootException != null) { 134 rootException.printStackTrace(s); 135 } 136 } 137 } 138 139 146 public void printStackTrace(PrintWriter s) { 147 synchronized (s) { 148 super.printStackTrace(s); 149 if (rootException != null) { 150 rootException.printStackTrace(s); 151 } 152 } 153 } 154 } 155 | Popular Tags |