diff --git a/liblangutil/ErrorReporter.cpp b/liblangutil/ErrorReporter.cpp index 8c8bb7ab05b8..cef34c5253af 100644 --- a/liblangutil/ErrorReporter.cpp +++ b/liblangutil/ErrorReporter.cpp @@ -23,6 +23,9 @@ #include #include + +#include + #include #include @@ -121,7 +124,7 @@ bool ErrorReporter::checkForExcessiveErrors(Error::Type _type) if (m_errorCount > c_maxErrorsAllowed) { m_errorList.push_back(std::make_shared(4013_error, Error::Type::Warning, "There are more than 256 errors. Aborting.")); - BOOST_THROW_EXCEPTION(FatalError()); + solThrow(FatalError, "There are more than 256 errors. Aborting."); } } @@ -131,13 +134,13 @@ bool ErrorReporter::checkForExcessiveErrors(Error::Type _type) void ErrorReporter::fatalError(ErrorId _error, Error::Type _type, SourceLocation const& _location, SecondarySourceLocation const& _secondaryLocation, std::string const& _description) { error(_error, _type, _location, _secondaryLocation, _description); - BOOST_THROW_EXCEPTION(FatalError()); + solThrow(FatalError, _description); } void ErrorReporter::fatalError(ErrorId _error, Error::Type _type, SourceLocation const& _location, std::string const& _description) { error(_error, _type, _location, _description); - BOOST_THROW_EXCEPTION(FatalError()); + solThrow(FatalError, _description); } ErrorList const& ErrorReporter::errors() const diff --git a/libsolidity/analysis/NameAndTypeResolver.cpp b/libsolidity/analysis/NameAndTypeResolver.cpp index 766f1bf121f5..af7ad6b4b80e 100644 --- a/libsolidity/analysis/NameAndTypeResolver.cpp +++ b/libsolidity/analysis/NameAndTypeResolver.cpp @@ -61,9 +61,14 @@ bool NameAndTypeResolver::registerDeclarations(SourceUnit& _sourceUnit, ASTNode { DeclarationRegistrationHelper registrar(m_scopes, _sourceUnit, m_errorReporter, m_globalContext, _currentScope); } - catch (langutil::FatalError const& error) + catch (FatalError const&) { - solAssert(m_errorReporter.hasErrors(), "Unreported fatal error: "s + error.what()); + if (!m_errorReporter.hasErrors()) + { + std::cerr << "Unreported fatal error:" << std::endl; + std::cerr << boost::current_exception_diagnostic_information() << std::endl; + solAssert(false, "Unreported fatal error."); + } return false; } return true; @@ -135,9 +140,14 @@ bool NameAndTypeResolver::resolveNamesAndTypes(SourceUnit& _source) return false; } } - catch (langutil::FatalError const& error) + catch (FatalError const&) { - solAssert(m_errorReporter.hasErrors(), "Unreported fatal error: "s + error.what()); + if (!m_errorReporter.hasErrors()) + { + std::cerr << "Unreported fatal error:" << std::endl; + std::cerr << boost::current_exception_diagnostic_information() << std::endl; + solAssert(false, "Unreported fatal error."); + } return false; } return true; @@ -150,9 +160,14 @@ bool NameAndTypeResolver::updateDeclaration(Declaration const& _declaration) m_scopes[nullptr]->registerDeclaration(_declaration, false, true); solAssert(_declaration.scope() == nullptr, "Updated declaration outside global scope."); } - catch (langutil::FatalError const& error) + catch (FatalError const&) { - solAssert(m_errorReporter.hasErrors(), "Unreported fatal error: "s + error.what()); + if (!m_errorReporter.hasErrors()) + { + std::cerr << "Unreported fatal error:" << std::endl; + std::cerr << boost::current_exception_diagnostic_information() << std::endl; + solAssert(false, "Unreported fatal error."); + } return false; } return true; diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index b461fa283026..18ee2c87c6d9 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -1324,7 +1324,7 @@ bool TypeChecker::visit(VariableDeclarationStatement const& _statement) solAssert(m_errorReporter.hasErrors(), "Should have errors!"); for (auto const& var: variables) if (var && !var->annotation().type) - BOOST_THROW_EXCEPTION(FatalError()); + solThrow(FatalError, "Type checker failed to determine types of all variables within the declaration."); } return false; @@ -1377,7 +1377,7 @@ bool TypeChecker::visit(Conditional const& _conditional) commonType = falseType; if (!trueType && !falseType) - BOOST_THROW_EXCEPTION(FatalError()); + solThrow(FatalError, "Both sides of the ternary expression have invalid types."); else if (trueType && falseType) { commonType = Type::commonType(trueType, falseType); diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 1791ad45a9d5..bf76ac3e943b 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -507,9 +507,14 @@ bool CompilerStack::analyze() else if (!analyzeLegacy(noErrors)) noErrors = false; } - catch (FatalError const& error) + catch (FatalError const&) { - solAssert(m_errorReporter.hasErrors(), "Unreported fatal error: "s + error.what()); + if (!m_errorReporter.hasErrors()) + { + std::cerr << "Unreported fatal error:" << std::endl; + std::cerr << boost::current_exception_diagnostic_information() << std::endl; + solAssert(false, "Unreported fatal error."); + } noErrors = false; } catch (UnimplementedFeatureError const& _error) @@ -1316,9 +1321,14 @@ StringMap CompilerStack::loadMissingSources(SourceUnit const& _ast) } } } - catch (FatalError const& error) + catch (FatalError const&) { - solAssert(m_errorReporter.hasErrors(), "Unreported fatal error: "s + error.what()); + if (!m_errorReporter.hasErrors()) + { + std::cerr << "Unreported fatal error:" << std::endl; + std::cerr << boost::current_exception_diagnostic_information() << std::endl; + solAssert(false, "Unreported fatal error."); + } } return newSources; } diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index 13303170d6ad..61b4b03db32f 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -176,9 +176,14 @@ ASTPointer Parser::parse(CharStream& _charStream) solAssert(m_recursionDepth == 0, ""); return nodeFactory.createNode(findLicenseString(nodes), nodes, m_experimentalSolidityEnabledInCurrentSourceUnit); } - catch (FatalError const& error) + catch (FatalError const&) { - solAssert(m_errorReporter.hasErrors(), "Unreported fatal error: "s + error.what()); + if (!m_errorReporter.hasErrors()) + { + std::cerr << "Unreported fatal error:" << std::endl; + std::cerr << boost::current_exception_diagnostic_information() << std::endl; + solAssert(false, "Unreported fatal error."); + } return nullptr; } } @@ -1475,7 +1480,7 @@ ASTPointer Parser::parseInlineAssembly(ASTPointer con yul::Parser asmParser(m_errorReporter, dialect); std::shared_ptr ast = asmParser.parseInline(m_scanner); if (ast == nullptr) - BOOST_THROW_EXCEPTION(FatalError()); + solThrow(FatalError, "Failed to parse inline assembly."); location.end = nativeLocationOf(ast->root()).end; return std::make_shared(nextID(), location, _docString, dialect, std::move(flags), ast); diff --git a/libyul/AsmAnalysis.cpp b/libyul/AsmAnalysis.cpp index b6dcbb08e2dc..fd643ec210be 100644 --- a/libyul/AsmAnalysis.cpp +++ b/libyul/AsmAnalysis.cpp @@ -75,13 +75,18 @@ bool AsmAnalyzer::analyze(Block const& _block) (*this)(_block); } - catch (FatalError const& error) + catch (FatalError const&) { // NOTE: There's a cap on the number of reported errors, but watcher.ok() will work fine even if // we exceed it because the reporter keeps counting (it just stops adding errors to the list). // Note also that fact of exceeding the cap triggers a FatalError so one can get thrown even // if we don't make any of our errors fatal. - yulAssert(!watcher.ok(), "Unreported fatal error: "s + error.what()); + if (watcher.ok()) + { + std::cerr << "Unreported fatal error:" << std::endl; + std::cerr << boost::current_exception_diagnostic_information() << std::endl; + yulAssert(false, "Unreported fatal error."); + } } return watcher.ok(); } diff --git a/libyul/AsmParser.cpp b/libyul/AsmParser.cpp index c061a251acd6..a6949d7f8bdb 100644 --- a/libyul/AsmParser.cpp +++ b/libyul/AsmParser.cpp @@ -127,9 +127,14 @@ std::unique_ptr Parser::parseInline(std::shared_ptr const& _scanne fetchDebugDataFromComment(); return std::make_unique(m_dialect, parseBlock()); } - catch (FatalError const& error) + catch (FatalError const&) { - yulAssert(m_errorReporter.hasErrors(), "Unreported fatal error: "s + error.what()); + if (!m_errorReporter.hasErrors()) + { + std::cerr << "Unreported fatal error:" << std::endl; + std::cerr << boost::current_exception_diagnostic_information() << std::endl; + yulAssert(false, "Unreported fatal error."); + } } return nullptr; diff --git a/libyul/ObjectParser.cpp b/libyul/ObjectParser.cpp index 954ade311f84..dfa604941ab5 100644 --- a/libyul/ObjectParser.cpp +++ b/libyul/ObjectParser.cpp @@ -63,9 +63,14 @@ std::shared_ptr ObjectParser::parse(std::shared_ptr const& _sca expectToken(Token::EOS); return object; } - catch (FatalError const& error) + catch (FatalError const&) { - yulAssert(m_errorReporter.hasErrors(), "Unreported fatal error: "s + error.what()); + if (!m_errorReporter.hasErrors()) + { + std::cerr << "Unreported fatal error:" << std::endl; + std::cerr << boost::current_exception_diagnostic_information() << std::endl; + yulAssert(false, "Unreported fatal error."); + } } return nullptr; }