diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-03-29 22:40:15 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2017-04-21 02:38:00 +0800 |
commit | b3c6b1e936b3cd10d6a871299fd19fb977c2363a (patch) | |
tree | 9b5e6409ac23c75ec06eb484a08d28b0a4872d31 | |
parent | 2c15e2b5412d0eff4b06ed0a44b1d5fdc219258b (diff) | |
download | dexon-solidity-b3c6b1e936b3cd10d6a871299fd19fb977c2363a.tar.gz dexon-solidity-b3c6b1e936b3cd10d6a871299fd19fb977c2363a.tar.zst dexon-solidity-b3c6b1e936b3cd10d6a871299fd19fb977c2363a.zip |
Refactor formatError
-rw-r--r-- | libsolidity/interface/StandardCompiler.cpp | 25 |
1 files changed, 19 insertions, 6 deletions
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; } |