1 61 62 package org.apache.commons.discovery; 63 64 65 74 public class DiscoveryException extends RuntimeException { 75 76 77 80 public DiscoveryException() { 81 super(); 82 } 83 84 89 public DiscoveryException(String message) { 90 super(message); 91 } 92 93 99 public DiscoveryException(Throwable cause) { 100 this((cause == null) ? null : cause.toString(), cause); 101 } 102 103 109 public DiscoveryException(String message, Throwable cause) { 110 super(message); 111 this.cause = cause; } 113 114 117 protected Throwable cause = null; 118 119 122 public Throwable getCause() { 123 return this.cause; 124 } 125 126 public String toString() { 127 String ls = System.getProperty("line.separator"); 128 String str = super.toString(); 129 if (cause != null) { 130 str = str + ls + 131 "*****" + ls + 132 stackToString(cause); 133 } 134 return str; 135 } 136 137 private static String stackToString(Throwable e){ 138 java.io.StringWriter sw= new java.io.StringWriter (1024); 139 java.io.PrintWriter pw= new java.io.PrintWriter (sw); 140 e.printStackTrace(pw); 141 pw.close(); 142 return sw.toString(); 143 } 144 } 145 | Popular Tags |