diff options
author | lloyd <[email protected]> | 2007-02-19 23:42:37 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2007-02-19 23:42:37 +0000 |
commit | 8253bc1e62ea10b80b4bbfdc8e95c8849237cda2 (patch) | |
tree | c05937e167cf6629d34404b5d0073fb39eca3c3f /checks/pk.cpp | |
parent | 54b95e6be5d3788497d461674869c0e0efc6e15c (diff) |
Eliminate most uses of exit() to bail on an error; instead throw an
exception upto the top level, that's what it's there for.
Diffstat (limited to 'checks/pk.cpp')
-rw-r--r-- | checks/pk.cpp | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/checks/pk.cpp b/checks/pk.cpp index 4ff798e00..b8bf0fc51 100644 --- a/checks/pk.cpp +++ b/checks/pk.cpp @@ -52,11 +52,8 @@ class Fixed_Output_RNG : public RandomNumberGenerator { if(position < output.size()) return output[position++]; - std::cout << "Fixed_Output_RNG: Ran out of bits" << std::endl; - std::exit(1); - // Annoying: some compilers warn if a return is here (unreachable - // code), others warn if it's not (no return from function). - /* return 0; */ + + throw Botan::Invalid_State("Fixed_Output_RNG: out of bits"); } void randomize(byte out[], u32bit len) throw() { @@ -101,10 +98,7 @@ u32bit do_pk_validation_tests(const std::string& filename) std::ifstream test_data(filename.c_str()); if(!test_data) - { - std::cout << "Couldn't open test file " << filename << std::endl; - std::exit(1); - } + throw Botan::Stream_IO_Error("Couldn't open test file " + filename); u32bit errors = 0, alg_count = 0; std::string algorithm, print_algorithm; @@ -112,10 +106,8 @@ u32bit do_pk_validation_tests(const std::string& filename) while(!test_data.eof()) { if(test_data.bad() || test_data.fail()) - { - std::cout << "File I/O error." << std::endl; - std::exit(1); - } + throw Botan::Stream_IO_Error("File I/O error reading from " + + filename); std::string line; std::getline(test_data, line); |