mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
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
This commit is contained in:
@@ -45,16 +45,16 @@ namespace test
|
||||
namespace
|
||||
{
|
||||
|
||||
bool parse(string const& _source, ErrorList& errors)
|
||||
bool parse(string const& _source, ErrorReporter& errorReporter)
|
||||
{
|
||||
try
|
||||
{
|
||||
auto scanner = make_shared<Scanner>(CharStream(_source));
|
||||
auto parserResult = assembly::Parser(errors, true).parse(scanner);
|
||||
auto parserResult = assembly::Parser(errorReporter, true).parse(scanner);
|
||||
if (parserResult)
|
||||
{
|
||||
assembly::AsmAnalysisInfo analysisInfo;
|
||||
return (assembly::AsmAnalyzer(analysisInfo, errors, true)).analyze(*parserResult);
|
||||
return (assembly::AsmAnalyzer(analysisInfo, errorReporter, true)).analyze(*parserResult);
|
||||
}
|
||||
}
|
||||
catch (FatalError const&)
|
||||
@@ -67,7 +67,8 @@ bool parse(string const& _source, ErrorList& errors)
|
||||
boost::optional<Error> parseAndReturnFirstError(string const& _source, bool _allowWarnings = true)
|
||||
{
|
||||
ErrorList errors;
|
||||
if (!parse(_source, errors))
|
||||
ErrorReporter errorReporter(errors);
|
||||
if (!parse(_source, errorReporter))
|
||||
{
|
||||
BOOST_REQUIRE_EQUAL(errors.size(), 1);
|
||||
return *errors.front();
|
||||
|
||||
Reference in New Issue
Block a user