Throwables.java
2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package com.google.common.base;
import com.google.common.annotations.Beta;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable;
public final class Throwables
{
@Beta
public static List<Throwable> getCausalChain(Throwable paramThrowable)
{
Preconditions.checkNotNull(paramThrowable);
ArrayList localArrayList = new ArrayList(4);
while (paramThrowable != null)
{
localArrayList.add(paramThrowable);
paramThrowable = paramThrowable.getCause();
}
return Collections.unmodifiableList(localArrayList);
}
public static Throwable getRootCause(Throwable paramThrowable)
{
for (;;)
{
Throwable localThrowable = paramThrowable.getCause();
if (localThrowable == null) {
break;
}
paramThrowable = localThrowable;
}
return paramThrowable;
}
public static String getStackTraceAsString(Throwable paramThrowable)
{
StringWriter localStringWriter = new StringWriter();
paramThrowable.printStackTrace(new PrintWriter(localStringWriter));
return localStringWriter.toString();
}
public static RuntimeException propagate(Throwable paramThrowable)
{
propagateIfPossible((Throwable)Preconditions.checkNotNull(paramThrowable));
throw new RuntimeException(paramThrowable);
}
public static <X extends Throwable> void propagateIfInstanceOf(@Nullable Throwable paramThrowable, Class<X> paramClass)
throws Throwable
{
if ((paramThrowable != null) && (paramClass.isInstance(paramThrowable))) {
throw ((Throwable)paramClass.cast(paramThrowable));
}
}
public static void propagateIfPossible(@Nullable Throwable paramThrowable)
{
propagateIfInstanceOf(paramThrowable, Error.class);
propagateIfInstanceOf(paramThrowable, RuntimeException.class);
}
public static <X extends Throwable> void propagateIfPossible(@Nullable Throwable paramThrowable, Class<X> paramClass)
throws Throwable
{
propagateIfInstanceOf(paramThrowable, paramClass);
propagateIfPossible(paramThrowable);
}
public static <X1 extends Throwable, X2 extends Throwable> void propagateIfPossible(@Nullable Throwable paramThrowable, Class<X1> paramClass, Class<X2> paramClass1)
throws Throwable, Throwable
{
Preconditions.checkNotNull(paramClass1);
propagateIfInstanceOf(paramThrowable, paramClass);
propagateIfPossible(paramThrowable, paramClass1);
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/google/common/base/Throwables.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/