1 16 package org.apache.commons.lang.exception; 17 18 import java.io.PrintStream ; 19 import java.io.PrintWriter ; 20 21 29 public class NestableError extends Error implements Nestable { 30 31 35 protected NestableDelegate delegate = new NestableDelegate(this); 36 37 41 private Throwable cause = null; 42 43 47 public NestableError() { 48 super(); 49 } 50 51 57 public NestableError(String msg) { 58 super(msg); 59 } 60 61 68 public NestableError(Throwable cause) { 69 super(); 70 this.cause = cause; 71 } 72 73 81 public NestableError(String msg, Throwable cause) { 82 super(msg); 83 this.cause = cause; 84 } 85 86 public Throwable getCause() { 87 return cause; 88 } 89 90 97 public String getMessage() { 98 if (super.getMessage() != null) { 99 return super.getMessage(); 100 } else if (cause != null) { 101 return cause.toString(); 102 } else { 103 return null; 104 } 105 } 106 107 public String getMessage(int index) { 108 if (index == 0) { 109 return super.getMessage(); 110 } else { 111 return delegate.getMessage(index); 112 } 113 } 114 115 public String [] getMessages() { 116 return delegate.getMessages(); 117 } 118 119 public Throwable getThrowable(int index) { 120 return delegate.getThrowable(index); 121 } 122 123 public int getThrowableCount() { 124 return delegate.getThrowableCount(); 125 } 126 127 public Throwable [] getThrowables() { 128 return delegate.getThrowables(); 129 } 130 131 public int indexOfThrowable(Class type) { 132 return delegate.indexOfThrowable(type, 0); 133 } 134 135 public int indexOfThrowable(Class type, int fromIndex) { 136 return delegate.indexOfThrowable(type, fromIndex); 137 } 138 139 public void printStackTrace() { 140 delegate.printStackTrace(); 141 } 142 143 public void printStackTrace(PrintStream out) { 144 delegate.printStackTrace(out); 145 } 146 147 public void printStackTrace(PrintWriter out) { 148 delegate.printStackTrace(out); 149 } 150 151 public final void printPartialStackTrace(PrintWriter out) { 152 super.printStackTrace(out); 153 } 154 } 155 | Popular Tags |