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
@@ -34,7 +34,6 @@
|
||||
#include "version.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "stmclient.h"
|
||||
@@ -177,11 +176,11 @@ int main( int argc, char *argv[] )
|
||||
|
||||
client.shutdown();
|
||||
} catch ( const Network::NetworkException& e ) {
|
||||
fprintf( stderr, "Network exception: %s: %s\r\n",
|
||||
e.function.c_str(), strerror( e.the_errno ) );
|
||||
fprintf( stderr, "Network exception: %s\r\n",
|
||||
e.what() );
|
||||
} catch ( const Crypto::CryptoException& e ) {
|
||||
fprintf( stderr, "Crypto exception: %s\r\n",
|
||||
e.text.c_str() );
|
||||
e.what() );
|
||||
} catch ( const std::string& s ) {
|
||||
fprintf( stderr, "Error: %s\r\n", s.c_str() );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user