From 35383f9b882bdbadb79f5729aca9cf32f7fce17a Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 15 Oct 2014 14:45:51 +0200 Subject: Added meaningful exception types. --- solidityNameAndTypeResolution.cpp | 9 +++++---- solidityParser.cpp | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/solidityNameAndTypeResolution.cpp b/solidityNameAndTypeResolution.cpp index 5a938e46..c9817eb4 100644 --- a/solidityNameAndTypeResolution.cpp +++ b/solidityNameAndTypeResolution.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include namespace dev { @@ -60,7 +61,7 @@ BOOST_AUTO_TEST_CASE(double_stateVariable_declaration) " uint256 variable;\n" " uint128 variable;\n" "}\n"; - BOOST_CHECK_THROW(parseTextAndResolveNames(text), std::exception); + BOOST_CHECK_THROW(parseTextAndResolveNames(text), DeclarationError); } BOOST_AUTO_TEST_CASE(double_function_declaration) @@ -69,7 +70,7 @@ BOOST_AUTO_TEST_CASE(double_function_declaration) " function fun() { var x; }\n" " function fun() { var x; }\n" "}\n"; - BOOST_CHECK_THROW(parseTextAndResolveNames(text), std::exception); + BOOST_CHECK_THROW(parseTextAndResolveNames(text), DeclarationError); } BOOST_AUTO_TEST_CASE(double_variable_declaration) @@ -77,7 +78,7 @@ BOOST_AUTO_TEST_CASE(double_variable_declaration) char const* text = "contract test {\n" " function f() { uint256 x; if (true) { uint256 x; } }\n" "}\n"; - BOOST_CHECK_THROW(parseTextAndResolveNames(text), std::exception); + BOOST_CHECK_THROW(parseTextAndResolveNames(text), DeclarationError); } BOOST_AUTO_TEST_CASE(name_shadowing) @@ -104,7 +105,7 @@ BOOST_AUTO_TEST_CASE(undeclared_name) " uint256 variable;\n" " function f(uint256 arg) { f(notfound); }" "}\n"; - BOOST_CHECK_THROW(parseTextAndResolveNames(text), std::exception); + BOOST_CHECK_THROW(parseTextAndResolveNames(text), DeclarationError); } BOOST_AUTO_TEST_SUITE_END() diff --git a/solidityParser.cpp b/solidityParser.cpp index 86d09f17..b1f27bcb 100644 --- a/solidityParser.cpp +++ b/solidityParser.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include namespace dev { @@ -54,8 +55,7 @@ BOOST_AUTO_TEST_CASE(missing_variable_name_in_declaration) char const* text = "contract test {\n" " uint256 ;\n" "}\n"; - cwarn << "The next error is expected."; - BOOST_CHECK_THROW(parseText(text), std::exception); + BOOST_CHECK_THROW(parseText(text), ParserError); } BOOST_AUTO_TEST_CASE(empty_function) -- cgit