aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-04-27 21:36:38 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-04-27 23:06:49 +0800
commit16276ab10b8f673fe9e4fe2a8e17bc752680ac8a (patch)
tree5a106d0f34b5d548f84eb9eead05e5cca211ee06 /libsolidity
parent122dc65b3608b368897701dbdebc689bc614933f (diff)
downloaddexon-solidity-16276ab10b8f673fe9e4fe2a8e17bc752680ac8a.tar.gz
dexon-solidity-16276ab10b8f673fe9e4fe2a8e17bc752680ac8a.tar.zst
dexon-solidity-16276ab10b8f673fe9e4fe2a8e17bc752680ac8a.zip
Catch assembler exceptions and throw readable Solidity exceptions
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/interface/CompilerStack.cpp37
1 files changed, 35 insertions, 2 deletions
diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp
index 6ea9ea78..05ac483d 100644
--- a/libsolidity/interface/CompilerStack.cpp
+++ b/libsolidity/interface/CompilerStack.cpp
@@ -657,8 +657,41 @@ 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&)
+ {
+ auto err = make_shared<Error>(Error::Type::InternalCompilerError);
+ *err << errinfo_comment("Assembly optimizer exception for bytecode");
+ m_errors.push_back(std::move(err);
+ }
+ catch(eth::AssemblyException const&)
+ {
+ auto err = make_shared<Error>(Error::Type::InternalCompilerError);
+ *err << errinfo_comment("Assembly exception for bytecode");
+ m_errors.push_back(std::move(err);
+ }
+
+ try
+ {
+ compiledContract.runtimeObject = compiler->runtimeObject();
+ }
+ catch(eth::OptimizerException const&)
+ {
+ auto err = make_shared<Error>(Error::Type::InternalCompilerError);
+ *err << errinfo_comment("Assembly optimizer exception for deployed bytecode");
+ m_errors.push_back(std::move(err);
+ }
+ catch(eth::AssemblyException const&)
+ {
+ auto err = make_shared<Error>(Error::Type::InternalCompilerError);
+ *err << errinfo_comment("Assembly exception for deployed bytecode");
+ m_errors.push_back(std::move(err);
+ }
+
compiledContract.onChainMetadata = onChainMetadata;
_compiledContracts[compiledContract.contract] = &compiler->assembly();