Merge pull request #2190 from ethereum/catch-asm-exceptions

Catch assembler exceptions and throw readable Solidity exceptions
This commit is contained in:
chriseth 2017-04-27 18:23:21 +02:00 committed by GitHub
commit 3926e8704a

View File

@ -657,8 +657,33 @@ void CompilerStack::compileContract(
cborEncodedMetadata += toCompactBigEndian(cborEncodedMetadata.size(), 2);
compiler->compileContract(_contract, _compiledContracts, cborEncodedMetadata);
compiledContract.compiler = compiler;
try
{
compiledContract.object = compiler->assembledObject();
}
catch(eth::OptimizerException const&)
{
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Assembly optimizer exception for bytecode"));
}
catch(eth::AssemblyException const&)
{
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Assembly exception for bytecode"));
}
try
{
compiledContract.runtimeObject = compiler->runtimeObject();
}
catch(eth::OptimizerException const&)
{
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Assembly optimizer exception for deployed bytecode"));
}
catch(eth::AssemblyException const&)
{
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Assembly exception for deployed bytecode"));
}
compiledContract.onChainMetadata = onChainMetadata;
_compiledContracts[compiledContract.contract] = &compiler->assembly();