From b3c6b1e936b3cd10d6a871299fd19fb977c2363a Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 29 Mar 2017 15:40:15 +0100 Subject: Refactor formatError --- libsolidity/interface/StandardCompiler.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'libsolidity') diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index 7fb715bf..8fa08647 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -30,18 +30,31 @@ using namespace std; using namespace dev; using namespace dev::solidity; -Json::Value formatFatalError(string const& _type, string const& _description) +Json::Value formatError( + bool _warning, + string const& _type, + string const& _component, + string const& _message, + string const& _formattedMessage = "", + Json::Value const& _sourceLocation = Json::Value() +) { Json::Value error = Json::objectValue; error["type"] = _type; - error["component"] = "general"; - error["severity"] = "error"; - error["message"] = _description; + error["component"] = _component; + error["severity"] = _warning ? "warning" : "error"; + error["message"] = _message; + error["formattedMessage"] = (_formattedMessage.length() > 0) ? _formattedMessage : _message; + if (_sourceLocation.isObject()) + error["sourceLocation"] = _sourceLocation; + return error; +} +Json::Value formatFatalError(string const& _type, string const& _message) +{ Json::Value output = Json::objectValue; output["errors"] = Json::arrayValue; - output["errors"].append(error); - + output["errors"].append(formatError(false, _type, "general", _message)); return output; } -- cgit