Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions liblangutil/Exceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ Error::Error(
*this << util::errinfo_comment(_description);
}

SourceLocation const* Error::sourceLocation() const noexcept
{
return boost::get_error_info<errinfo_sourceLocation>(*this);
}

SecondarySourceLocation const* Error::secondarySourceLocation() const noexcept
{
return boost::get_error_info<errinfo_secondarySourceLocation>(*this);
}

optional<Error::Severity> Error::severityFromString(string _input)
{
boost::algorithm::to_lower(_input);
Expand Down
5 changes: 4 additions & 1 deletion liblangutil/Exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ class Error: virtual public util::Exception
Type type() const { return m_type; }
std::string const& typeName() const { return m_typeName; }

SourceLocation const* sourceLocation() const noexcept;
SecondarySourceLocation const* secondarySourceLocation() const noexcept;

/// helper functions
static Error const* containsErrorOfType(ErrorList const& _list, Error::Type _type)
{
Expand All @@ -206,7 +209,7 @@ class Error: virtual public util::Exception
return nullptr;
}

static Severity errorSeverity(Type _type)
static constexpr Severity errorSeverity(Type _type)
{
if (_type == Type::Info)
return Severity::Info;
Expand Down
2 changes: 1 addition & 1 deletion libsolidity/interface/StandardCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Json::Value formatErrorWithException(
_charStreamProvider
);

if (string const* description = boost::get_error_info<util::errinfo_comment>(_exception))
if (string const* description = _exception.comment())
message = ((_message.length() > 0) ? (_message + ":") : "") + *description;
else
message = _message;
Expand Down
2 changes: 0 additions & 2 deletions libsolutil/Exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ struct Exception: virtual std::exception, virtual boost::exception

/// @returns the errinfo_comment of this exception.
std::string const* comment() const noexcept;

private:
};

/// Throws an exception with a given description and extra information about the location the
Expand Down
2 changes: 1 addition & 1 deletion test/libsolidity/AnalysisFramework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ ErrorList AnalysisFramework::filterErrors(ErrorList const& _errorList, bool _inc
for (auto const& messagePrefix: m_messagesToCut)
if (currentError->comment()->find(messagePrefix) == 0)
{
SourceLocation const* location = boost::get_error_info<errinfo_sourceLocation>(*currentError);
SourceLocation const* location = currentError->sourceLocation();
// sufficient for now, but in future we might clone the error completely, including the secondary location
newError = make_shared<Error>(
currentError->errorId(),
Expand Down
5 changes: 3 additions & 2 deletions test/libsolidity/SyntaxTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ void SyntaxTest::filterObtainedErrors()
{
for (auto const& currentError: filterErrors(compiler().errors(), true))
{
int locationStart = -1, locationEnd = -1;
int locationStart = -1;
int locationEnd = -1;
string sourceName;
if (auto location = boost::get_error_info<errinfo_sourceLocation>(*currentError))
if (SourceLocation const* location = currentError->sourceLocation())
{
solAssert(location->sourceName, "");
sourceName = *location->sourceName;
Expand Down
2 changes: 1 addition & 1 deletion test/libyul/SyntaxTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void SyntaxTest::parseAndAnalyze()
int locationStart = -1;
int locationEnd = -1;

if (auto location = boost::get_error_info<errinfo_sourceLocation>(*error))
if (SourceLocation const* location = error->sourceLocation())
{
locationStart = location->start;
locationEnd = location->end;
Expand Down