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:
Geoffrey Thomas
2013-08-03 16:32:23 -07:00
committed by John Hood
parent ebecb9bd3a
commit 5721b392ab
11 changed files with 41 additions and 30 deletions
+3 -2
View File
@@ -40,6 +40,7 @@
#include <vector>
#include <limits.h>
#include <exception>
namespace Overlay {
using namespace Terminal;
@@ -173,10 +174,10 @@ namespace Overlay {
show_quit_keystroke = s_show_quit_keystroke;
}
void set_network_exception( const NetworkException &e )
void set_network_exception( const std::exception &e )
{
wchar_t tmp[ 128 ];
swprintf( tmp, 128, L"%s: %s", e.function.c_str(), strerror( e.the_errno ) );
swprintf( tmp, 128, L"%s", e.what() );
message = tmp;
message_is_network_exception = true;