aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libdevcore/Exceptions.h3
-rw-r--r--libsolidity/interface/Exceptions.cpp14
-rw-r--r--solc/jsonCompiler.cpp6
3 files changed, 20 insertions, 3 deletions
diff --git a/libdevcore/Exceptions.h b/libdevcore/Exceptions.h
index 4622774a..37cdbed9 100644
--- a/libdevcore/Exceptions.h
+++ b/libdevcore/Exceptions.h
@@ -41,6 +41,9 @@ struct Exception: virtual std::exception, virtual boost::exception
Exception(std::string _message = std::string()): m_message(std::move(_message)) {}
const char* what() const noexcept override { return m_message.empty() ? std::exception::what() : m_message.c_str(); }
+ /// @returns "FileName:LineNumber" referring to the point where the exception was thrown.
+ std::string lineInfo() const;
+
private:
std::string m_message;
};
diff --git a/libsolidity/interface/Exceptions.cpp b/libsolidity/interface/Exceptions.cpp
index 90a680b4..41890b91 100644
--- a/libsolidity/interface/Exceptions.cpp
+++ b/libsolidity/interface/Exceptions.cpp
@@ -23,6 +23,7 @@
#include <libsolidity/interface/Exceptions.h>
#include <libsolidity/interface/Utils.h>
+using namespace std;
using namespace dev;
using namespace dev::solidity;
@@ -56,3 +57,16 @@ Error::Error(Type _type): m_type(_type)
break;
}
}
+
+string Exception::lineInfo() const
+{
+ char const* const* file = boost::get_error_info<boost::throw_file>(*this);
+ int const* line = boost::get_error_info<boost::throw_line>(*this);
+ string ret;
+ if (file)
+ ret += *file;
+ ret += ':';
+ if (line)
+ ret += boost::lexical_cast<string>(*line);
+ return ret;
+}
diff --git a/solc/jsonCompiler.cpp b/solc/jsonCompiler.cpp
index d761b541..6ebd1a55 100644
--- a/solc/jsonCompiler.cpp
+++ b/solc/jsonCompiler.cpp
@@ -184,15 +184,15 @@ string compile(StringMap const& _sources, bool _optimize, CStyleReadFileCallback
}
catch (CompilerError const& exception)
{
- errors.append(formatError(exception, "Compiler error", scannerFromSourceName));
+ errors.append(formatError(exception, "Compiler error (" + exception.lineInfo() + ")", scannerFromSourceName));
}
catch (InternalCompilerError const& exception)
{
- errors.append(formatError(exception, "Internal compiler error", scannerFromSourceName));
+ errors.append(formatError(exception, "Internal compiler error (" + exception.lineInfo() + ")", scannerFromSourceName));
}
catch (UnimplementedFeatureError const& exception)
{
- errors.append(formatError(exception, "Unimplemented feature", scannerFromSourceName));
+ errors.append(formatError(exception, "Unimplemented feature (" + exception.lineInfo() + ")", scannerFromSourceName));
}
catch (Exception const& exception)
{