From e24c35bce04225f5301a65108889f9487bf5d7c5 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Sun, 23 Apr 2017 19:43:06 +0100 Subject: [PATCH 1/4] Be a bit more verbose and capture Boost exceptions in StandardCompiler --- libsolidity/interface/StandardCompiler.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index 4a8787b3e..5408db2ec 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -413,9 +413,13 @@ Json::Value StandardCompiler::compile(Json::Value const& _input) { return compileInternal(_input); } + catch (Exception const& _exception) + { + return formatFatalError("InternalCompilerError", "Internal exception in StandardCompiler::compileInternal: " + boost::diagnostic_information(_exception)); + } catch (...) { - return formatFatalError("InternalCompilerError", "Internal exception in StandardCompiler::compilerInternal"); + return formatFatalError("InternalCompilerError", "Internal exception in StandardCompiler::compileInternal"); } } From 4a3fb9638179a4a7d4b40afb44308e56573c63e0 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 24 Apr 2017 11:25:24 +0100 Subject: [PATCH 2/4] Enable standard json in the docs --- docs/using-the-compiler.rst | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/using-the-compiler.rst b/docs/using-the-compiler.rst index 9e9a5eb66..deaa1329a 100644 --- a/docs/using-the-compiler.rst +++ b/docs/using-the-compiler.rst @@ -37,15 +37,13 @@ Either add ``--libraries "Math:0x12345678901234567890 Heap:0xabcdef0123456"`` to If ``solc`` is called with the option ``--link``, all input files are interpreted to be unlinked binaries (hex-encoded) in the ``__LibraryName____``-format given above and are linked in-place (if the input is read from stdin, it is written to stdout). All options except ``--libraries`` are ignored (including ``-o``) in this case. +If ``solc`` is called with the option ``--standard-json``, it will expect a JSON input (as explained below) on the standard input, and return a JSON output on the standard output. + .. _compiler-api: Compiler Input and Output JSON Description ****************************************** -.. warning:: - - This JSON interface is not yet supported by the Solidity compiler, but will be released in a future version. - These JSON formats are used by the compiler API as well as are available through ``solc``. These are subject to change, some fields are optional (as noted), but it is aimed at to only make backwards compatible changes. From 3cd02ca1481131773e8bde952c6d7f76dec4ed3a Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 24 Apr 2017 11:25:33 +0100 Subject: [PATCH 3/4] Change error type names to not include spaces --- libsolidity/interface/Exceptions.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libsolidity/interface/Exceptions.cpp b/libsolidity/interface/Exceptions.cpp index 968a24ad1..c09180de4 100644 --- a/libsolidity/interface/Exceptions.cpp +++ b/libsolidity/interface/Exceptions.cpp @@ -33,22 +33,22 @@ Error::Error(Type _type, SourceLocation const& _location, string const& _descrip switch(m_type) { case Type::DeclarationError: - m_typeName = "Declaration Error"; + m_typeName = "DeclarationError"; break; case Type::DocstringParsingError: - m_typeName = "Docstring Parsing Error"; + m_typeName = "DocstringParsingError"; break; case Type::ParserError: - m_typeName = "Parser Error"; + m_typeName = "ParserError"; break; case Type::SyntaxError: - m_typeName = "Syntax Error"; + m_typeName = "SyntaxError"; break; case Type::TypeError: - m_typeName = "Type Error"; + m_typeName = "TypeError"; break; case Type::Why3TranslatorError: - m_typeName = "Why3 Translator Error"; + m_typeName = "Why3TranslatorError"; break; case Type::Warning: m_typeName = "Warning"; From 43eb8398711f7fafd703cff06092f3dfd2b0e748 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 24 Apr 2017 11:44:33 +0100 Subject: [PATCH 4/4] Do not fail if parsing failed in StandardCompiler --- libsolidity/interface/StandardCompiler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index 5408db2ec..6a8417de5 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -337,7 +337,7 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input) } Json::Value contractsOutput = Json::objectValue; - for (string const& contractName: m_compilerStack.contractNames()) + for (string const& contractName: success ? m_compilerStack.contractNames() : vector()) { size_t colon = contractName.find(':'); solAssert(colon != string::npos, "");