Make all exception classes inherit from std::exception
This refactors out a very common pattern of formatting "%s: %s" with e.function.c_str() and strerror( e.the_errno ) into just the what() method of NetworkException. It's also a prerequisite for making cleaner public API for any exceptions we throw, and allows us to more easily get exceptions passed back to us to handle.
This commit is contained in:
committed by
John Hood
parent
ebecb9bd3a
commit
5721b392ab
+4
-1
@@ -38,18 +38,21 @@
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <exception>
|
||||
|
||||
using std::string;
|
||||
|
||||
long int myatoi( const char *str );
|
||||
|
||||
namespace Crypto {
|
||||
class CryptoException {
|
||||
class CryptoException : public std::exception {
|
||||
public:
|
||||
string text;
|
||||
bool fatal;
|
||||
CryptoException( string s_text, bool s_fatal = false )
|
||||
: text( s_text ), fatal( s_fatal ) {};
|
||||
const char *what() const throw () { return text.c_str(); }
|
||||
~CryptoException() throw () {}
|
||||
};
|
||||
|
||||
/* 16-byte-aligned buffer, with length. */
|
||||
|
||||
Reference in New Issue
Block a user