aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-04-28 00:23:21 +0800
committerGitHub <noreply@github.com>2017-04-28 00:23:21 +0800
commit3926e8704af00062c33e392fcaef70510df7012e (patch)
tree039efc594c3170ee7d4e43f6d8a933d17ac73a1b
parenta8cf9f8178f276b6cc626accb20a52cdd60bf104 (diff)
parentb0485e327bfe229b4193c59ea490c7fac0dae7aa (diff)
downloaddexon-solidity-3926e8704af00062c33e392fcaef70510df7012e.tar.gz
dexon-solidity-3926e8704af00062c33e392fcaef70510df7012e.tar.zst
dexon-solidity-3926e8704af00062c33e392fcaef70510df7012e.zip
Merge pull request #2190 from ethereum/catch-asm-exceptions
Catch assembler exceptions and throw readable Solidity exceptions
-rw-r--r--libsolidity/interface/CompilerStack.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp
index 6ea9ea78..b09435a8 100644
--- a/libsolidity/interface/CompilerStack.cpp
+++ b/libsolidity/interface/CompilerStack.cpp
@@ -657,8 +657,33 @@ void CompilerStack::compileContract(
cborEncodedMetadata += toCompactBigEndian(cborEncodedMetadata.size(), 2);
compiler->compileContract(_contract, _compiledContracts, cborEncodedMetadata);
compiledContract.compiler = compiler;
- compiledContract.object = compiler->assembledObject();
- compiledContract.runtimeObject = compiler->runtimeObject();
+
+ 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();