From b64a71330292bd72a38a3c56fd1a1694a2eb15a3 Mon Sep 17 00:00:00 2001 From: Luke Imhoff Date: Sun, 6 Aug 2017 21:58:57 -0500 Subject: [PATCH] Include specific message for each decompilation error reason --- src/org/elixir_lang/beam/Decompiler.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/org/elixir_lang/beam/Decompiler.java b/src/org/elixir_lang/beam/Decompiler.java index d5952a2b5..5c7c8a380 100644 --- a/src/org/elixir_lang/beam/Decompiler.java +++ b/src/org/elixir_lang/beam/Decompiler.java @@ -19,6 +19,7 @@ import java.util.List; import java.util.SortedSet; +import static org.elixir_lang.beam.chunk.Chunk.TypeID.ATOM; import static org.elixir_lang.psi.call.name.Function.DEF; import static org.elixir_lang.psi.call.name.Function.DEFMACRO; import static org.elixir_lang.psi.call.name.Module.ELIXIR_PREFIX; @@ -36,7 +37,7 @@ public class Decompiler implements BinaryFileDecompiler { @NotNull private static CharSequence decompiled(@Nullable Beam beam) { - StringBuilder decompiled = new StringBuilder("Decompilation Error"); + StringBuilder decompiled = new StringBuilder("# Decompilation Error: "); if (beam != null) { Atoms atoms = beam.atoms(); @@ -57,8 +58,14 @@ private static CharSequence decompiled(@Nullable Beam beam) { appendExports(decompiled, beam, atoms); decompiled.append("end\n"); + } else { + decompiled.append("No module name found in ").append(ATOM).append(" chunk in BEAM"); } + } else { + decompiled.append("No ").append(ATOM).append(" chunk found in BEAM"); } + } else { + decompiled.append("BEAM format could not be read"); } return decompiled;