From 960b5fa032b0b948bb44876615e3e8c53a043325 Mon Sep 17 00:00:00 2001 From: chriseth Date: Fri, 3 Mar 2017 18:44:28 +0100 Subject: [PATCH] Error constructor. --- libsolidity/interface/Exceptions.cpp | 8 +++++++- libsolidity/interface/Exceptions.h | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/libsolidity/interface/Exceptions.cpp b/libsolidity/interface/Exceptions.cpp index 41890b91a..406ebbfb1 100644 --- a/libsolidity/interface/Exceptions.cpp +++ b/libsolidity/interface/Exceptions.cpp @@ -27,7 +27,8 @@ using namespace std; using namespace dev; using namespace dev::solidity; -Error::Error(Type _type): m_type(_type) +Error::Error(Type _type, SourceLocation const& _location, string const& _description): + m_type(_type) { switch(m_type) { @@ -56,6 +57,11 @@ Error::Error(Type _type): m_type(_type) solAssert(false, ""); break; } + + if (!_location.isEmpty()) + *this << errinfo_sourceLocation(_location); + if (!_description.empty()) + *this << errinfo_comment(_description); } string Exception::lineInfo() const diff --git a/libsolidity/interface/Exceptions.h b/libsolidity/interface/Exceptions.h index 81716c41a..f4b9fd59a 100644 --- a/libsolidity/interface/Exceptions.h +++ b/libsolidity/interface/Exceptions.h @@ -53,7 +53,11 @@ public: Warning }; - explicit Error(Type _type); + explicit Error( + Type _type, + SourceLocation const& _location = SourceLocation(), + std::string const& _description = std::string() + ); Type type() const { return m_type; } std::string const& typeName() const { return m_typeName; }