From 3970ee9cf7978c462390d49e083deb740d71c6fe Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 27 Jun 2008 06:16:42 +0000 Subject: [PATCH] Use SystemError at appropriate places --- source/datagramsocket.cpp | 6 +++--- source/socket.cpp | 6 +++--- source/streamlistensocket.cpp | 4 ++-- source/streamsocket.cpp | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/source/datagramsocket.cpp b/source/datagramsocket.cpp index 1394ffa..9779bfe 100644 --- a/source/datagramsocket.cpp +++ b/source/datagramsocket.cpp @@ -25,7 +25,7 @@ int DatagramSocket::connect(const SockAddr &addr) int err=::connect(handle, &sa, size); if(err==-1) - throw Exception(format("Unable to connect: %s", strerror(errno))); + throw SystemError("Unable to connect", errno); delete peer_addr; peer_addr=addr.copy(); @@ -56,7 +56,7 @@ unsigned DatagramSocket::sendto(const char *buf, unsigned size, const SockAddr & if(errno==EAGAIN) return 0; else - throw Exception(format("Sendto failed: %s", strerror(errno))); + throw SystemError("Sendto failed", errno); } return ret; @@ -78,7 +78,7 @@ unsigned DatagramSocket::recvfrom(char *buf, unsigned size, SockAddr *&addr_) if(errno==EAGAIN) return 0; else - throw Exception(format("Recvfrom failed: %s", strerror(errno))); + throw SystemError("Recvfrom failed", errno); } addr_=SockAddr::create(addr); diff --git a/source/socket.cpp b/source/socket.cpp index decdbeb..fcd686f 100644 --- a/source/socket.cpp +++ b/source/socket.cpp @@ -77,7 +77,7 @@ void Socket::bind(const SockAddr &addr) int err=::bind(handle, &sa, size); if(err==-1) - throw Exception(format("Unable to bind: %s", strerror(errno))); + throw SystemError("Unable to bind", errno); delete local_addr; local_addr=addr.copy(); @@ -187,7 +187,7 @@ unsigned Socket::do_write(const char *buf, unsigned size) if(errno==EAGAIN) return 0; else - throw Exception(format("Writing to socket failed: %s", strerror(errno))); + throw SystemError("Writing to socket failed", errno); } return ret; @@ -206,7 +206,7 @@ unsigned Socket::do_read(char *buf, unsigned size) if(errno==EAGAIN) return 0; else - throw Exception(format("Reading from socket failed: %s", strerror(errno))); + throw SystemError("Reading from socket failed", errno); } else if(ret==0 && !eof_flag) { diff --git a/source/streamlistensocket.cpp b/source/streamlistensocket.cpp index df80b00..2a8bc3d 100644 --- a/source/streamlistensocket.cpp +++ b/source/streamlistensocket.cpp @@ -5,7 +5,7 @@ Copyright © 2008 Mikkosoft Productions, Mikko Rasa Distributed under the LGPL */ -#include +#include #include #include #include "streamlistensocket.h" @@ -30,7 +30,7 @@ void StreamListenSocket::listen(const SockAddr &addr, unsigned backlog) int err=::listen(handle, backlog); if(err==-1) - throw Exception(format("Unable to listen: %s", strerror(errno))); + throw SystemError("Unable to listen", errno); #ifdef WIN32 WSAEventSelect(handle, event, FD_ACCEPT); diff --git a/source/streamsocket.cpp b/source/streamsocket.cpp index cf1a7b5..0f69111 100644 --- a/source/streamsocket.cpp +++ b/source/streamsocket.cpp @@ -8,7 +8,7 @@ Distributed under the LGPL #ifndef WIN32 #include #endif -#include +#include #include #include #include "streamsocket.h" @@ -41,7 +41,7 @@ int StreamSocket::poll_connect(const Time::TimeDelta &timeout) #ifdef WIN32 throw Exception(format("Connection polling failed: %d", WSAGetLastError())); #else - throw Exception(format("Connection polling failed: %s", strerror(errno))); + throw SystemError("Connection polling failed", errno); #endif else if(res>0) { @@ -57,7 +57,7 @@ int StreamSocket::poll_connect(const Time::TimeDelta &timeout) #ifdef WIN32 throw Exception(format("Connection failed: %d", err)); #else - throw Exception(format("Connection failed: %s", strerror(err))); + throw SystemError("Connection failed", err); #endif } @@ -116,7 +116,7 @@ int StreamSocket::connect(const SockAddr &addr) set_events(IO::P_OUTPUT); } else - throw Exception(format("Unable to connect: %s", strerror(errno))); + throw SystemError("Unable to connect", errno); } #endif -- 2.43.0