diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-03-29 20:34:16 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2017-04-21 02:38:00 +0800 |
commit | 4eaee772b3b4afab9d47ab50327fe451ebff22f4 (patch) | |
tree | c7caa7cc1fc3413102dbc050815ee4df9ba878c8 | |
parent | f8cb0766d4da0c651999a9e6b9b158216b0a47cb (diff) | |
download | dexon-solidity-4eaee772b3b4afab9d47ab50327fe451ebff22f4.tar.gz dexon-solidity-4eaee772b3b4afab9d47ab50327fe451ebff22f4.tar.zst dexon-solidity-4eaee772b3b4afab9d47ab50327fe451ebff22f4.zip |
Capture error messages from the JSON parser
-rw-r--r-- | libsolidity/interface/StandardCompiler.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index e5de39a8..c6a83bab 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -178,15 +178,21 @@ Json::Value StandardCompiler::compile(Json::Value const& _input) } catch (...) { - return "{\"errors\":\"[{\"type\":\"InternalCompilerError\",\"component\":\"general\",\"severity\":\"error\",\"message\":\"Internal exception in StandardCompiler::compilerInternal\"}]}"; + return formatFatalError("InternalCompilerError", "Internal exception in StandardCompiler::compilerInternal"); } } string StandardCompiler::compile(string const& _input) { Json::Value input; + Json::Reader reader; - if (!Json::Reader().parse(_input, input, false)) + try + { + if (!reader.parse(_input, input, false)) + return jsonCompactPrint(formatFatalError("JSONError", reader.getFormattedErrorMessages())); + } + catch(...) { return "{\"errors\":\"[{\"type\":\"JSONError\",\"component\":\"general\",\"severity\":\"error\",\"message\":\"Error parsing input JSON.\"}]}"; } |