1 22 package org.jboss.util; 23 24 import java.io.PrintWriter ; 25 import java.io.PrintStream ; 26 27 34 public class NestedError 35 extends Error 36 implements NestedThrowable 37 { 38 39 protected final Throwable nested; 40 41 47 public NestedError(final String msg) { 48 super(msg); 49 this.nested = null; 50 } 51 52 59 public NestedError(final String msg, final Throwable nested) { 60 super(msg); 61 this.nested = nested; 62 NestedThrowable.Util.checkNested(this, nested); 63 } 64 65 71 public NestedError(final Throwable nested) { 72 this(nested.getMessage(), nested); 73 } 74 75 78 public NestedError() { 79 super(); 80 this.nested = null; 81 } 82 83 88 public Throwable getNested() { 89 return nested; 90 } 91 92 99 public Throwable getCause() { 100 return nested; 101 } 102 103 108 public String getMessage() { 109 return NestedThrowable.Util.getMessage(super.getMessage(), nested); 110 } 111 112 118 public void printStackTrace(final PrintStream stream) { 119 if (nested == null || NestedThrowable.PARENT_TRACE_ENABLED) { 120 super.printStackTrace(stream); 121 } 122 NestedThrowable.Util.print(nested, stream); 123 } 124 125 131 public void printStackTrace(final PrintWriter writer) { 132 if (nested == null || NestedThrowable.PARENT_TRACE_ENABLED) { 133 super.printStackTrace(writer); 134 } 135 NestedThrowable.Util.print(nested, writer); 136 } 137 138 142 public void printStackTrace() { 143 printStackTrace(System.err); 144 } 145 } 146 | Popular Tags |