diff --git a/dependencies/socketw/sw_base.cxx b/dependencies/socketw/sw_base.cxx index 38dbaa4d..4924fd17 100644 --- a/dependencies/socketw/sw_base.cxx +++ b/dependencies/socketw/sw_base.cxx @@ -96,28 +96,17 @@ void WSA_exit(void) //== Error handling mode //==================================================================== bool sw_DoThrow = false; -bool sw_Verbose = true; void sw_setThrowMode(bool throw_errors) { sw_DoThrow = throw_errors; } -void sw_setVerboseMode(bool verbose) -{ - sw_Verbose = verbose; -} - bool sw_getThrowMode(void) { return sw_DoThrow; } -bool sw_getVerboseMode(void) -{ - return sw_Verbose; -} - //==================================================================== //== Base error class @@ -178,7 +167,6 @@ SWBaseSocket::SWBaseSocket() recv_close = false; //init values - error_string = ""; block_mode = blocking; fsend_ready = true; frecv_ready = true; @@ -292,7 +280,9 @@ bool SWBaseSocket::disconnect(SWBaseError *error) } if( n != 0 ){ - set_error(error, err, error_string); + char err_str[100]; + snprintf(err_str, 100, "SWBaseSocket::disconnect() - recv() failed with code %d", n); + set_error(error, err, err_str); return false; //error } @@ -633,12 +623,6 @@ bool SWBaseSocket::waitWrite(SWBaseError *error) return waitIO(tmp, error); } -void SWBaseSocket::print_error() -{ - if( error_string.size() > 0 ) - fprintf(stderr, "%s!\n", error_string.c_str()); -} - void SWBaseSocket::handle_errno(SWBaseError *error, string msg) { #ifndef _WIN32 @@ -745,24 +729,16 @@ void SWBaseSocket::no_error(SWBaseError *error) void SWBaseSocket::set_error(SWBaseError *error, SWBaseError name, string msg) { - error_string = msg; - - if(error != NULL){ + if( sw_DoThrow ){ + SWBaseError e; + e = name; + e.error_string = msg; + e.failed_class = this; + throw e; + } else if(error != NULL){ *error = name; error->error_string = msg; error->failed_class = this; - }else{ - if( sw_Verbose ) - print_error(); - - if( sw_DoThrow ){ - SWBaseError e; - e = name; - e.error_string = msg; - e.failed_class = this; - throw e; - }else - exit(-1); } } diff --git a/dependencies/socketw/sw_base.h b/dependencies/socketw/sw_base.h index 8d4fce8b..b93566dd 100644 --- a/dependencies/socketw/sw_base.h +++ b/dependencies/socketw/sw_base.h @@ -30,9 +30,7 @@ // // Default is throw_errors == false and verbose == true void sw_setThrowMode(bool throw_errors); -void sw_setVerboseMode(bool verbose); bool sw_getThrowMode(void); -bool sw_getVerboseMode(void); // Abstract base class for streaming sockets @@ -151,10 +149,6 @@ class DECLSPEC SWBaseSocket // and others that use those, i.e. all frecvmsg(). void set_timeout(Uint32 sec, Uint32 usec){ tsec = sec, tusec = usec; } - // Error handling - virtual void print_error(); //prints the last error if any to stderr - virtual std::string get_error(){return error_string;} //returns a human readable error string - protected: // get a new socket if myfd < 0 virtual void get_socket()=0; @@ -178,9 +172,6 @@ class DECLSPEC SWBaseSocket // our socket descriptor int myfd; - - // last error - std::string error_string; // data for fsend bool fsend_ready;