From 37330ca005c648c681dd3ca20ec64e912492a417 Mon Sep 17 00:00:00 2001 From: Eric Frias Date: Fri, 9 May 2014 11:50:18 -0400 Subject: [PATCH] change the naming of invalidOperation exception to the more fc-friendly invalid_operation, and add an implementation so it can be used. --- include/fc/exception/exception.hpp | 2 +- src/exception.cpp | 38 +++++++++++++++++++----------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/include/fc/exception/exception.hpp b/include/fc/exception/exception.hpp index 2db45d2..5b02e24 100644 --- a/include/fc/exception/exception.hpp +++ b/include/fc/exception/exception.hpp @@ -171,7 +171,7 @@ namespace fc FC_DECLARE_EXCEPTION( out_of_range_exception, "Out of Range" ); /** @brief if an operation is unsupported or not valid this may be thrown */ - FC_DECLARE_EXCEPTION( invalidOperation_exception, "Invalid Operation" ); + FC_DECLARE_EXCEPTION( invalid_operation_exception, "Invalid Operation" ); /** * @brief used to report a canceled Operation diff --git a/src/exception.cpp b/src/exception.cpp index 8a73ab3..e6f7c0f 100644 --- a/src/exception.cpp +++ b/src/exception.cpp @@ -24,6 +24,7 @@ namespace fc eof_exception_code = 11, db_in_use_exception_code = 12, std_exception_code = 14, + invalid_operation_exception_code = 15 }; void to_variant( detail::exception_code e, variant& v ) @@ -69,6 +70,9 @@ namespace fc case db_in_use_exception_code: v = "db_in_use"; break; + case invalid_operation_exception_code: + v = "invalid_operation"; + break; case unspecified_exception_code: default: v = "unspecified"; @@ -79,20 +83,21 @@ namespace fc void from_variant( const variant& e, detail::exception_code& ll ) { string v = e.as_string(); - if( v == "unspecified" ) ll = unspecified_exception_code; - else if( v == "unhandled" ) ll = unhandled_exception_code; - else if( v == "timeout" ) ll = timeout_exception_code; - else if( v == "key_not_found" ) ll = key_not_found_exception_code; - else if( v == "bad_cast" ) ll = bad_cast_exception_code; - else if( v == "file_not_found" ) ll = file_not_found_exception_code; - else if( v == "parse_error" ) ll = parse_error_exception_code; - else if( v == "invalid_arg" ) ll = invalid_arg_exception_code; - else if( v == "out_of_range" ) ll = out_of_range_exception_code; - else if( v == "canceled" ) ll = canceled_exception_code; - else if( v == "assert" ) ll = assert_exception_code; - else if( v == "std" ) ll = std_exception_code; - else if( v == "eof" ) ll = eof_exception_code; - else if( v == "db_in_use") ll = db_in_use_exception_code; + if( v == "unspecified" ) ll = unspecified_exception_code; + else if( v == "unhandled" ) ll = unhandled_exception_code; + else if( v == "timeout" ) ll = timeout_exception_code; + else if( v == "key_not_found" ) ll = key_not_found_exception_code; + else if( v == "bad_cast" ) ll = bad_cast_exception_code; + else if( v == "file_not_found" ) ll = file_not_found_exception_code; + else if( v == "parse_error" ) ll = parse_error_exception_code; + else if( v == "invalid_arg" ) ll = invalid_arg_exception_code; + else if( v == "out_of_range" ) ll = out_of_range_exception_code; + else if( v == "canceled" ) ll = canceled_exception_code; + else if( v == "assert" ) ll = assert_exception_code; + else if( v == "std" ) ll = std_exception_code; + else if( v == "eof" ) ll = eof_exception_code; + else if( v == "db_in_use") ll = db_in_use_exception_code; + else if( v == "invalid_operation") ll = invalid_operation_exception_code; else FC_THROW_EXCEPTION( bad_cast_exception, "Invalid Error Report _code '${code}'", ("code", v) ); @@ -178,6 +183,7 @@ namespace fc FC_EXCEPTION_IMPL(key_not_found_exception) FC_EXCEPTION_IMPL(bad_cast_exception) FC_EXCEPTION_IMPL(out_of_range_exception) + FC_EXCEPTION_IMPL(invalid_operation_exception); FC_EXCEPTION_IMPL(canceled_exception) FC_EXCEPTION_IMPL(assert_exception) FC_EXCEPTION_IMPL(eof_exception) @@ -295,6 +301,8 @@ namespace fc throw eof_exception( my->_elog ); case detail::db_in_use_exception_code: throw db_in_use_exception( my->_elog ); + case detail::invalid_operation_exception_code: + throw invalid_operation_exception( my->_elog ); case detail::std_exception_code: throw std_exception( *this ); case detail::unspecified_exception_code: @@ -330,6 +338,8 @@ namespace fc return std::make_shared( my->_elog ); case detail::db_in_use_exception_code: return std::make_shared( my->_elog ); + case detail::invalid_operation_exception_code: + return std::make_shared( my->_elog ); case detail::std_exception_code: return std::make_shared( *this ); case detail::unspecified_exception_code: