| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
package com.drew.lang; |
| 22 |
|
| 23 |
import com.drew.lang.annotations.NotNull; |
| 24 |
import com.drew.lang.annotations.Nullable; |
| 25 |
|
| 26 |
import java.io.PrintStream; |
| 27 |
import java.io.PrintWriter; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
public class CompoundException extends Exception |
| 37 |
{ |
| 38 |
private static final long serialVersionUID = -9207883813472069925L; |
| 39 |
|
| 40 |
@Nullable |
| 41 |
private final Throwable _innerException; |
| 42 |
|
| 43 |
public CompoundException(@Nullable String msg) |
| 44 |
{ |
| 45 |
this(msg, null); |
| 46 |
} |
| 47 |
|
| 48 |
public CompoundException(@Nullable Throwable exception) |
| 49 |
{ |
| 50 |
this(null, exception); |
| 51 |
} |
| 52 |
|
| 53 |
public CompoundException(@Nullable String msg, @Nullable Throwable innerException) |
| 54 |
{ |
| 55 |
super(msg); |
| 56 |
_innerException = innerException; |
| 57 |
} |
| 58 |
|
| 59 |
@Nullable |
| 60 |
public Throwable getInnerException() |
| 61 |
{ |
| 62 |
return _innerException; |
| 63 |
} |
| 64 |
|
| 65 |
@Override |
| 66 |
@NotNull |
| 67 |
public String toString() |
| 68 |
{ |
| 69 |
StringBuilder string = new StringBuilder(); |
| 70 |
string.append(super.toString()); |
| 71 |
if (_innerException != null) { |
| 72 |
string.append("\n"); |
| 73 |
string.append("--- inner exception ---"); |
| 74 |
string.append("\n"); |
| 75 |
string.append(_innerException.toString()); |
| 76 |
} |
| 77 |
return string.toString(); |
| 78 |
} |
| 79 |
|
| 80 |
@Override |
| 81 |
public void printStackTrace(@NotNull PrintStream s) |
| 82 |
{ |
| 83 |
super.printStackTrace(s); |
| 84 |
if (_innerException != null) { |
| 85 |
s.println("--- inner exception ---"); |
| 86 |
_innerException.printStackTrace(s); |
| 87 |
} |
| 88 |
} |
| 89 |
|
| 90 |
@Override |
| 91 |
public void printStackTrace(@NotNull PrintWriter s) |
| 92 |
{ |
| 93 |
super.printStackTrace(s); |
| 94 |
if (_innerException != null) { |
| 95 |
s.println("--- inner exception ---"); |
| 96 |
_innerException.printStackTrace(s); |
| 97 |
} |
| 98 |
} |
| 99 |
|
| 100 |
@Override |
| 101 |
public void printStackTrace() |
| 102 |
{ |
| 103 |
super.printStackTrace(); |
| 104 |
if (_innerException != null) { |
| 105 |
System.err.println("--- inner exception ---"); |
| 106 |
_innerException.printStackTrace(); |
| 107 |
} |
| 108 |
} |
| 109 |
} |