summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiam Miller-Cushon <cushon@google.com>2016-02-10 09:50:43 -0800
committerBenoit Lamarche <benoitlamarche@google.com>2016-02-22 18:10:36 +0100
commit900c3b497902357345a9444a972ac0a3bea1f09c (patch)
treebd066fa5b51ac0dc409f510296c2fd93f0c816bd
parent0e3b9ceebc7c0a1778c502cdc750c2eb7bbcfe6f (diff)
downloaddalvik-900c3b497902357345a9444a972ac0a3bea1f09c.tar.gz
Improve dx error handling
If a class file cannot be parsed, print the error message and context (including file name), and omit the stack trace unless --debug is enabled. Bug: 25075831 (cherry picked from commit bd156605a787bbbb5524b6b25254b37a67e6dd7f) Change-Id: I1615591e6c389e2c99bbc024da22a59abe62a3a2
-rw-r--r--dx/src/com/android/dx/command/dexer/Main.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/dx/src/com/android/dx/command/dexer/Main.java b/dx/src/com/android/dx/command/dexer/Main.java
index e7c63b8a1..e42eb54f1 100644
--- a/dx/src/com/android/dx/command/dexer/Main.java
+++ b/dx/src/com/android/dx/command/dexer/Main.java
@@ -753,6 +753,9 @@ public class Main {
try {
new DirectClassFileConsumer(name, bytes, null).call(
new ClassParserTask(name, bytes).call());
+ } catch (ParseException ex) {
+ // handled in FileBytesConsumer
+ throw ex;
} catch(Exception ex) {
throw new RuntimeException("Exception parsing classes", ex);
}
@@ -1658,6 +1661,14 @@ public class Main {
DxConsole.err.println("\nEXCEPTION FROM SIMULATION:");
DxConsole.err.println(ex.getMessage() + "\n");
DxConsole.err.println(((SimException) ex).getContext());
+ } else if (ex instanceof ParseException) {
+ DxConsole.err.println("\nPARSE ERROR:");
+ ParseException parseException = (ParseException) ex;
+ if (args.debug) {
+ parseException.printStackTrace(DxConsole.err);
+ } else {
+ parseException.printContext(DxConsole.err);
+ }
} else {
DxConsole.err.println("\nUNEXPECTED TOP-LEVEL EXCEPTION:");
ex.printStackTrace(DxConsole.err);