From a18b153e1940b6e1504084c60f3feca46dfa2870 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 12 May 2016 14:35:58 -0700 Subject: use exceptions consistently to report input errors --- src/wasm-as.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/wasm-as.cpp') diff --git a/src/wasm-as.cpp b/src/wasm-as.cpp index eb03f853a..6995859a7 100644 --- a/src/wasm-as.cpp +++ b/src/wasm-as.cpp @@ -49,7 +49,7 @@ int main(int argc, const char *argv[]) { if (options.debug) std::cerr << "w-parsing..." << std::endl; Module wasm; - SExpressionWasmBuilder builder(wasm, *root[0], [&]() { abort(); }); + SExpressionWasmBuilder builder(wasm, *root[0]); if (options.debug) std::cerr << "binarification..." << std::endl; BufferWithRandomAccess buffer(options.debug); -- cgit v1.2.3 From c8293a3f9112ad486f6f3639fc5680d73e7559ca Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 12 May 2016 16:02:03 -0700 Subject: show parse errors in wasm-dis and wasm-as --- src/wasm-as.cpp | 17 +++++++++++------ src/wasm-dis.cpp | 9 +++++++-- 2 files changed, 18 insertions(+), 8 deletions(-) (limited to 'src/wasm-as.cpp') diff --git a/src/wasm-as.cpp b/src/wasm-as.cpp index 6995859a7..40839ea55 100644 --- a/src/wasm-as.cpp +++ b/src/wasm-as.cpp @@ -43,13 +43,18 @@ int main(int argc, const char *argv[]) { auto input(read_file(options.extra["infile"], Flags::Text, options.debug ? Flags::Debug : Flags::Release)); - if (options.debug) std::cerr << "s-parsing..." << std::endl; - SExpressionParser parser(const_cast(input.c_str())); - Element& root = *parser.root; - - if (options.debug) std::cerr << "w-parsing..." << std::endl; Module wasm; - SExpressionWasmBuilder builder(wasm, *root[0]); + + try{ + if (options.debug) std::cerr << "s-parsing..." << std::endl; + SExpressionParser parser(const_cast(input.c_str())); + Element& root = *parser.root; + if (options.debug) std::cerr << "w-parsing..." << std::endl; + SExpressionWasmBuilder builder(wasm, *root[0]); + } catch (ParseException& p) { + p.dump(std::cerr); + Fatal() << "error in parsing wasm binary"; + } if (options.debug) std::cerr << "binarification..." << std::endl; BufferWithRandomAccess buffer(options.debug); diff --git a/src/wasm-dis.cpp b/src/wasm-dis.cpp index e2e103b46..93c286913 100644 --- a/src/wasm-dis.cpp +++ b/src/wasm-dis.cpp @@ -45,8 +45,13 @@ int main(int argc, const char *argv[]) { if (options.debug) std::cerr << "parsing binary..." << std::endl; Module wasm; - WasmBinaryBuilder parser(wasm, input, options.debug); - parser.read(); + try { + WasmBinaryBuilder parser(wasm, input, options.debug); + parser.read(); + } catch (ParseException& p) { + p.dump(std::cerr); + Fatal() << "error in parsing wasm binary"; + } if (options.debug) std::cerr << "Printing..." << std::endl; Output output(options.extra["output"], Flags::Text, options.debug ? Flags::Debug : Flags::Release); -- cgit v1.2.3