Catch more exceptions in jsonCompiler.

This commit is contained in:
chriseth 2016-09-01 20:14:00 +02:00
parent b5d941d3d9
commit 52ee47190d

View File

@ -202,6 +202,8 @@ string compile(StringMap const& _sources, bool _optimize, CStyleReadFileCallback
output["errors"] = errors;
if (success)
{
try
{
output["contracts"] = Json::Value(Json::objectValue);
for (string const& contractName: compiler.contractNames())
@ -246,8 +248,20 @@ string compile(StringMap const& _sources, bool _optimize, CStyleReadFileCallback
for (auto const& source: compiler.sourceNames())
output["sources"][source]["AST"] = ASTJsonConverter(compiler.ast(source), compiler.sourceIndices()).json();
}
catch (...)
{
output["errors"].append("Unknown exception while generating compiler output.");
}
}
try
{
return Json::FastWriter().write(output);
}
catch (...)
{
return "{\"errors\":[\"Unknown error while generating JSON.\"]}";
}
}
string compileMulti(string const& _input, bool _optimize, CStyleReadFileCallback _readCallback = nullptr)