summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2021-07-13 00:36:50 +0430
committerAli Mohammad Pur <ali.mpfard@gmail.com>2021-07-17 01:13:39 +0430
commitbacf5a7220ce2301c3b1e72d049b276f2e7c4d4e (patch)
treeaa16f7b672af321c9ca7ad06e6a9a7fc886b2f52
parent23b48f8fe127bd631522b7235e51ea3b8e66835d (diff)
downloadserenity-bacf5a7220ce2301c3b1e72d049b276f2e7c4d4e.zip
wasm: Don't try to print the function results if it traps
-rw-r--r--Userland/Utilities/wasm.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/Userland/Utilities/wasm.cpp b/Userland/Utilities/wasm.cpp
index 008bb2b273..3229aefb4b 100644
--- a/Userland/Utilities/wasm.cpp
+++ b/Userland/Utilities/wasm.cpp
@@ -512,14 +512,16 @@ int main(int argc, char* argv[])
if (debug)
launch_repl();
- if (result.is_trap())
- warnln("Execution trapped!");
- if (!result.values().is_empty())
- warnln("Returned:");
- for (auto& value : result.values()) {
- Wasm::Printer printer { stream };
- g_stdout.write(" -> "sv.bytes());
- g_printer.print(value);
+ if (result.is_trap()) {
+ warnln("Execution trapped: {}", result.trap().reason);
+ } else {
+ if (!result.values().is_empty())
+ warnln("Returned:");
+ for (auto& value : result.values()) {
+ Wasm::Printer printer { stream };
+ g_stdout.write(" -> "sv.bytes());
+ g_printer.print(value);
+ }
}
}
}