Catch Throwable instead of Exception
This commit is contained in:
1 parent
8c3796605e
commit
bfd85e9bc7
17 files changed
+179
-113
No files matched your search
@@ -35,7 +35,7 @@ public final class ExceptionUtils {
|
||||
private static final String TAG = ExceptionUtils.class.getSimpleName();
|
||||
|
||||
@NonNull
|
||||
public static String getReadableString(@NonNull Exception e) {
|
||||
public static String getReadableString(@NonNull Throwable e) {
|
||||
e.printStackTrace();
|
||||
if (e instanceof MalformedURLException) {
|
||||
return GetText.getString(R.string.error_invalid_url);
|
||||
@@ -62,4 +62,15 @@ public final class ExceptionUtils {
|
||||
return GetText.getString(R.string.error_unknown);
|
||||
}
|
||||
}
|
||||
|
||||
public static void throwIfFatal(@NonNull Throwable t) {
|
||||
// values here derived from https://github.com/ReactiveX/RxJava/issues/748#issuecomment-32471495
|
||||
if (t instanceof VirtualMachineError) {
|
||||
throw (VirtualMachineError) t;
|
||||
} else if (t instanceof ThreadDeath) {
|
||||
throw (ThreadDeath) t;
|
||||
} else if (t instanceof LinkageError) {
|
||||
throw (LinkageError) t;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,8 @@ public final class PackageUtils {
|
||||
} else {
|
||||
Log.e(TAG, "Can't find signature in package " + packageName);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
ExceptionUtils.throwIfFatal(e);
|
||||
Log.e(TAG, "Can't find package " + packageName, e);
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in new issue
Block a user