diff options
author | Christian <c@ethdev.com> | 2014-10-15 20:45:51 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2014-10-16 00:41:29 +0800 |
commit | df142782bc3a1435f70d9f5f4c8e04ae8d7e1678 (patch) | |
tree | 363823cbff0362b1e47e8e22b8cb8c482308a49f /NameAndTypeResolver.cpp | |
parent | 89b794f1dc15c8688526470b9d68b361dab82be3 (diff) | |
download | dexon-solidity-df142782bc3a1435f70d9f5f4c8e04ae8d7e1678.tar.gz dexon-solidity-df142782bc3a1435f70d9f5f4c8e04ae8d7e1678.tar.zst dexon-solidity-df142782bc3a1435f70d9f5f4c8e04ae8d7e1678.zip |
Added meaningful exception types.
Diffstat (limited to 'NameAndTypeResolver.cpp')
-rw-r--r-- | NameAndTypeResolver.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/NameAndTypeResolver.cpp b/NameAndTypeResolver.cpp index 33b550eb..8e769c47 100644 --- a/NameAndTypeResolver.cpp +++ b/NameAndTypeResolver.cpp @@ -23,6 +23,7 @@ #include <libsolidity/NameAndTypeResolver.h> #include <libsolidity/AST.h> +#include <libsolidity/Exceptions.h> #include <boost/assert.hpp> namespace dev { @@ -115,7 +116,7 @@ void NameAndTypeResolver::resolveReferencesInFunction(ParameterList& _returnPara virtual bool visit(Identifier& _identifier) override { Declaration* declaration = m_resolver.getNameFromCurrentScope(_identifier.getName()); if (declaration == nullptr) - throw std::exception(); // @todo + BOOST_THROW_EXCEPTION(DeclarationError() << errinfo_comment("Undeclared identifier.")); _identifier.setReferencedDeclaration(*declaration); return false; } @@ -151,10 +152,11 @@ void NameAndTypeResolver::registerVariableDeclarationAndResolveType(VariableDecl virtual bool visit(UserDefinedTypeName& _typeName) override { Declaration* declaration = m_resolver.getNameFromCurrentScope(_typeName.getName()); if (declaration == nullptr) - throw std::exception(); // @todo + BOOST_THROW_EXCEPTION(DeclarationError() << errinfo_comment("Undeclared identifier.")); StructDefinition* referencedStruct = dynamic_cast<StructDefinition*>(declaration); + //@todo later, contracts are also valid types if (referencedStruct == nullptr) - throw std::exception(); // @todo we only allow structs as user defined types (later also contracts) + BOOST_THROW_EXCEPTION(TypeError() << errinfo_comment("Identifier does not name a type name.")); _typeName.setReferencedStruct(*referencedStruct); return false; } @@ -176,7 +178,7 @@ void NameAndTypeResolver::registerVariableDeclarationAndResolveType(VariableDecl void NameAndTypeResolver::registerDeclaration(Declaration& _declaration) { if (!m_currentScope->registerDeclaration(_declaration)) - throw std::exception(); // @todo + BOOST_THROW_EXCEPTION(DeclarationError() << errinfo_comment("Identifier already declared.")); } Declaration* NameAndTypeResolver::getNameFromCurrentScope(ASTString const& _name, bool _recursive) |