aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-01-07 23:40:24 +0000
committerlloyd <[email protected]>2010-01-07 23:40:24 +0000
commit9900914a225c97aca575df268f73f7c6c366e697 (patch)
tree4f5525cc27e8473379f4965bb9b1dd7e1df109a3 /src/utils
parent667738924ba1fde5bf219d963b433594d53d63b9 (diff)
parent2837e915d82e439730624f15bfc8c820475c9d65 (diff)
merge of 'bf0e5684d8ba5fb0a21cdcd11d26995cbb250c4a'
and 'e30a741f6014987e9683842ede22c44b2db03c56'
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/exceptn.h83
-rw-r--r--src/utils/parsing.cpp2
2 files changed, 18 insertions, 67 deletions
diff --git a/src/utils/exceptn.h b/src/utils/exceptn.h
index d106de1c0..86efebc7c 100644
--- a/src/utils/exceptn.h
+++ b/src/utils/exceptn.h
@@ -1,6 +1,6 @@
/*
* Exceptions
-* (C) 1999-2007 Jack Lloyd
+* (C) 1999-2009 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
@@ -16,32 +16,8 @@
namespace Botan {
-/*
-* Exception Base Class
-*/
-class BOTAN_DLL Exception : public std::exception
- {
- public:
- Exception(const std::string& m = "Unknown error") :
- msg("Botan: " + m)
- {}
-
- const char* what() const throw() { return msg.c_str(); }
-
- virtual ~Exception() throw() {}
- private:
- std::string msg;
- };
-
-/*
-* Invalid_Argument Exception
-*/
-struct BOTAN_DLL Invalid_Argument : public Exception
- {
- Invalid_Argument(const std::string& err = "") :
- Exception(err)
- {}
- };
+typedef std::runtime_error Exception;
+typedef std::invalid_argument Invalid_Argument;
/*
* Invalid_State Exception
@@ -54,16 +30,6 @@ struct BOTAN_DLL Invalid_State : public Exception
};
/*
-* Format_Error Exception
-*/
-struct BOTAN_DLL Format_Error : public Exception
- {
- Format_Error(const std::string& err = "") :
- Exception(err)
- {}
- };
-
-/*
* Lookup_Error Exception
*/
struct BOTAN_DLL Lookup_Error : public Exception
@@ -150,29 +116,29 @@ struct BOTAN_DLL Algorithm_Not_Found : public Lookup_Error
/*
* Invalid_Algorithm_Name Exception
*/
-struct BOTAN_DLL Invalid_Algorithm_Name : public Format_Error
+struct BOTAN_DLL Invalid_Algorithm_Name : public Invalid_Argument
{
Invalid_Algorithm_Name(const std::string& name):
- Format_Error("Invalid algorithm name: " + name)
+ Invalid_Argument("Invalid algorithm name: " + name)
{}
};
/*
* Encoding_Error Exception
*/
-struct BOTAN_DLL Encoding_Error : public Format_Error
+struct BOTAN_DLL Encoding_Error : public Invalid_Argument
{
Encoding_Error(const std::string& name) :
- Format_Error("Encoding error: " + name) {}
+ Invalid_Argument("Encoding error: " + name) {}
};
/*
* Decoding_Error Exception
*/
-struct BOTAN_DLL Decoding_Error : public Format_Error
+struct BOTAN_DLL Decoding_Error : public Invalid_Argument
{
Decoding_Error(const std::string& name) :
- Format_Error("Decoding error: " + name) {}
+ Invalid_Argument("Decoding error: " + name) {}
};
/*
@@ -195,37 +161,22 @@ struct BOTAN_DLL Stream_IO_Error : public Exception
};
/*
-* Configuration Error Exception
-*/
-struct BOTAN_DLL Config_Error : public Format_Error
- {
- Config_Error(const std::string& err) :
- Format_Error("Config error: " + err)
- {}
-
- Config_Error(const std::string& err, u32bit line) :
- Format_Error("Config error at line " + to_string(line) + ": " + err)
- {}
- };
-
-/*
-* Integrity Failure Exception
+* Self Test Failure Exception
*/
-struct BOTAN_DLL Integrity_Failure : public Internal_Error
+struct BOTAN_DLL Self_Test_Failure : public Internal_Error
{
- Integrity_Failure(const std::string& err) :
- Internal_Error("Integrity failure: " + err)
+ Self_Test_Failure(const std::string& err) :
+ Internal_Error("Self test failed: " + err)
{}
};
/*
-* Self Test Failure Exception
+* Memory Allocation Exception
*/
-struct BOTAN_DLL Self_Test_Failure : public Internal_Error
+struct BOTAN_DLL Memory_Exhaustion : public std::bad_alloc
{
- Self_Test_Failure(const std::string& err) :
- Internal_Error("Self test failed: " + err)
- {}
+ const char* what() const throw()
+ { return "Ran out of memory, allocation failed"; }
};
}
diff --git a/src/utils/parsing.cpp b/src/utils/parsing.cpp
index 58a8e0b38..4b99ac1ec 100644
--- a/src/utils/parsing.cpp
+++ b/src/utils/parsing.cpp
@@ -168,7 +168,7 @@ std::vector<std::string> split_on(const std::string& str, char delim)
}
if(substr == "")
- throw Format_Error("Unable to split string: " + str);
+ throw Invalid_Argument("Unable to split string: " + str);
elems.push_back(substr);
return elems;