diff options
author | Rhett Aultman <roadriverrail@gmail.com> | 2017-05-11 21:26:35 +0800 |
---|---|---|
committer | Rhett Aultman <roadriverrail@gmail.com> | 2017-05-30 22:28:31 +0800 |
commit | 89b60ffbd4c2dde26fa5e9f1d750729b5c89373e (patch) | |
tree | a4c464d4d40baaa260f071c1028f347bd287e44d /libsolidity/analysis/ReferencesResolver.cpp | |
parent | 0066a08aa8f6c469cde7947ec50ca662a32123a0 (diff) | |
download | dexon-solidity-89b60ffbd4c2dde26fa5e9f1d750729b5c89373e.tar.gz dexon-solidity-89b60ffbd4c2dde26fa5e9f1d750729b5c89373e.tar.zst dexon-solidity-89b60ffbd4c2dde26fa5e9f1d750729b5c89373e.zip |
Refactor error reporting
This commit introduces ErrorReporter, a utility class which consolidates
all of the error logging functionality into a common set of functions.
It also replaces all direct interactions with an ErrorList with calls to
an ErrorReporter.
This commit resolves issue #2209
Diffstat (limited to 'libsolidity/analysis/ReferencesResolver.cpp')
-rw-r--r-- | libsolidity/analysis/ReferencesResolver.cpp | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp index f5fffb57..b70b0f0e 100644 --- a/libsolidity/analysis/ReferencesResolver.cpp +++ b/libsolidity/analysis/ReferencesResolver.cpp @@ -28,6 +28,7 @@ #include <libsolidity/inlineasm/AsmAnalysis.h> #include <libsolidity/inlineasm/AsmAnalysisInfo.h> #include <libsolidity/inlineasm/AsmData.h> +#include <libsolidity/interface/ErrorReporter.h> #include <boost/algorithm/string.hpp> @@ -111,7 +112,7 @@ void ReferencesResolver::endVisit(FunctionTypeName const& _typeName) case VariableDeclaration::Visibility::External: break; default: - typeError(_typeName.location(), "Invalid visibility, can only be \"external\" or \"internal\"."); + fatalTypeError(_typeName.location(), "Invalid visibility, can only be \"external\" or \"internal\"."); } if (_typeName.isPayable() && _typeName.visibility() != VariableDeclaration::Visibility::External) @@ -165,7 +166,8 @@ bool ReferencesResolver::visit(InlineAssembly const& _inlineAssembly) // the type and size of external identifiers, which would result in false errors. // The only purpose of this step is to fill the inline assembly annotation with // external references. - ErrorList errorsIgnored; + ErrorList errors; + ErrorReporter errorsIgnored(errors); julia::ExternalIdentifierAccess::Resolver resolver = [&](assembly::Identifier const& _identifier, julia::IdentifierContext) { auto declarations = m_resolver.nameFromCurrentScope(_identifier.name); @@ -303,29 +305,19 @@ void ReferencesResolver::endVisit(VariableDeclaration const& _variable) void ReferencesResolver::typeError(SourceLocation const& _location, string const& _description) { - auto err = make_shared<Error>(Error::Type::TypeError); - *err << errinfo_sourceLocation(_location) << errinfo_comment(_description); m_errorOccurred = true; - m_errors.push_back(err); + m_errorReporter.typeError(_location, _description); } void ReferencesResolver::fatalTypeError(SourceLocation const& _location, string const& _description) { - typeError(_location, _description); - BOOST_THROW_EXCEPTION(FatalError()); -} - -void ReferencesResolver::declarationError(SourceLocation const& _location, string const& _description) -{ - auto err = make_shared<Error>(Error::Type::DeclarationError); - *err << errinfo_sourceLocation(_location) << errinfo_comment(_description); m_errorOccurred = true; - m_errors.push_back(err); + m_errorReporter.fatalTypeError(_location, _description); } void ReferencesResolver::fatalDeclarationError(SourceLocation const& _location, string const& _description) { - declarationError(_location, _description); - BOOST_THROW_EXCEPTION(FatalError()); + m_errorOccurred = true; + m_errorReporter.fatalDeclarationError(_location, _description); } |