From a95c86e8e4b328e1fe4aad742d7d700326c6c283 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 2 May 2017 18:55:39 +0100 Subject: Catch errors gracefully in CLI assembler --- solc/CommandLineInterface.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'solc/CommandLineInterface.cpp') diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 63d41cdf..0f2e83dc 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -985,13 +985,26 @@ bool CommandLineInterface::assemble() map> scanners; for (auto const& src: m_sourceCodes) { - auto scanner = make_shared(CharStream(src.second), src.first); - scanners[src.first] = scanner; - if (!m_assemblyStacks[src.first].parse(scanner)) - successful = false; - else - //@TODO we should not just throw away the result here - m_assemblyStacks[src.first].assemble(); + try + { + auto scanner = make_shared(CharStream(src.second), src.first); + scanners[src.first] = scanner; + if (!m_assemblyStacks[src.first].parse(scanner)) + successful = false; + else + //@TODO we should not just throw away the result here + m_assemblyStacks[src.first].assemble(); + } + catch (Exception const& _exception) + { + cerr << "Exception in assembler: " << boost::diagnostic_information(_exception) << endl; + return false; + } + catch (...) + { + cerr << "Unknown exception in assembler." << endl; + return false; + } } for (auto const& stack: m_assemblyStacks) { -- cgit v1.2.3