aboutsummaryrefslogtreecommitdiffstats
path: root/solc
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-09-23 20:42:54 +0800
committerchriseth <c@ethdev.com>2015-09-23 20:42:54 +0800
commitefdea76d5eb026777e89b8683413184bf8c5287d (patch)
treed13122099f0ad3e5b65dd263a87f0e653db6e672 /solc
parent028f561dac6aec0692daa8217b0ee1e3a0c5aa72 (diff)
parente32a063a10b41efeffeec451188b2f3466c8b308 (diff)
downloaddexon-solidity-efdea76d5eb026777e89b8683413184bf8c5287d.tar
dexon-solidity-efdea76d5eb026777e89b8683413184bf8c5287d.tar.gz
dexon-solidity-efdea76d5eb026777e89b8683413184bf8c5287d.tar.bz2
dexon-solidity-efdea76d5eb026777e89b8683413184bf8c5287d.tar.lz
dexon-solidity-efdea76d5eb026777e89b8683413184bf8c5287d.tar.xz
dexon-solidity-efdea76d5eb026777e89b8683413184bf8c5287d.tar.zst
dexon-solidity-efdea76d5eb026777e89b8683413184bf8c5287d.zip
Merge pull request #85 from chriseth/warnings
Support mulitple errors and warnings.
Diffstat (limited to 'solc')
-rw-r--r--solc/CommandLineInterface.cpp7
-rw-r--r--solc/jsonCompiler.cpp34
2 files changed, 26 insertions, 15 deletions
diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp
index cfc8a5e0..587dcded 100644
--- a/solc/CommandLineInterface.cpp
+++ b/solc/CommandLineInterface.cpp
@@ -490,7 +490,12 @@ bool CommandLineInterface::processInput()
// TODO: Perhaps we should not compile unless requested
bool optimize = m_args.count("optimize") > 0;
unsigned runs = m_args["optimize-runs"].as<unsigned>();
- m_compiler->compile(optimize, runs);
+ if (!m_compiler->compile(optimize, runs))
+ {
+ for (auto const& error: m_compiler->errors())
+ SourceReferenceFormatter::printExceptionInformation(cerr, *error, "Error", *m_compiler);
+ return false;
+ }
m_compiler->link(m_libraries);
}
catch (ParserError const& _exception)
diff --git a/solc/jsonCompiler.cpp b/solc/jsonCompiler.cpp
index d265ed9c..ba3e6912 100644
--- a/solc/jsonCompiler.cpp
+++ b/solc/jsonCompiler.cpp
@@ -46,10 +46,7 @@ string formatError(Exception const& _exception, string const& _name, CompilerSta
{
ostringstream errorOutput;
SourceReferenceFormatter::printExceptionInformation(errorOutput, _exception, _name, _compiler);
-
- Json::Value output(Json::objectValue);
- output["error"] = errorOutput.str();
- return Json::FastWriter().write(output);
+ return errorOutput.str();
}
Json::Value functionHashes(ContractDefinition const& _contract)
@@ -123,43 +120,52 @@ string compile(string _input, bool _optimize)
sources[""] = _input;
Json::Value output(Json::objectValue);
+ Json::Value errors(Json::arrayValue);
CompilerStack compiler;
try
{
- compiler.compile(_input, _optimize);
+ if (!compiler.compile(_input, _optimize))
+ {
+ for (auto const& error: compiler.errors())
+ errors.append(formatError(*error, "Error", compiler));
+ }
}
catch (ParserError const& exception)
{
- return formatError(exception, "Parser error", compiler);
+ errors.append(formatError(exception, "Parser error", compiler));
}
catch (DeclarationError const& exception)
{
- return formatError(exception, "Declaration error", compiler);
+ errors.append(formatError(exception, "Declaration error", compiler));
}
catch (TypeError const& exception)
{
- return formatError(exception, "Type error", compiler);
+ errors.append(formatError(exception, "Type error", compiler));
}
catch (CompilerError const& exception)
{
- return formatError(exception, "Compiler error", compiler);
+ errors.append(formatError(exception, "Compiler error", compiler));
}
catch (InternalCompilerError const& exception)
{
- return formatError(exception, "Internal compiler error", compiler);
+ errors.append(formatError(exception, "Internal compiler error", compiler));
}
catch (DocstringParsingError const& exception)
{
- return formatError(exception, "Documentation parsing error", compiler);
+ errors.append(formatError(exception, "Documentation parsing error", compiler));
}
catch (Exception const& exception)
{
- output["error"] = "Exception during compilation: " + boost::diagnostic_information(exception);
- return Json::FastWriter().write(output);
+ errors.append("Exception during compilation: " + boost::diagnostic_information(exception));
}
catch (...)
{
- output["error"] = "Unknown exception during compilation.";
+ errors.append("Unknown exception during compilation.");
+ }
+
+ if (errors.size() > 0)
+ {
+ output["errors"] = errors;
return Json::FastWriter().write(output);
}