]> git.tdb.fi Git - libs/net.git/commitdiff
Adjust exception classes and messages
authorMikko Rasa <tdb@tdb.fi>
Fri, 9 Dec 2022 18:31:16 +0000 (20:31 +0200)
committerMikko Rasa <tdb@tdb.fi>
Fri, 9 Dec 2022 18:32:28 +0000 (20:32 +0200)
source/http/client.cpp
source/http/client.h
source/net/communicator.h
source/net/serversocket.cpp
source/net/socket.cpp
source/net/socket.h
source/net/unix/unix.cpp
source/net/windows/unix.cpp

index e09057684957cac17acdeb17adeaf272efdc1952..705f4cb7bbd0a7e09dcdbcde3dc979e9bf0cae86 100644 (file)
@@ -1,3 +1,4 @@
+#include <msp/core/except.h>
 #include <msp/core/refptr.h>
 #include <msp/net/resolve.h>
 #include <msp/time/timedelta.h>
@@ -53,7 +54,7 @@ void Client::use_resolver(Net::Resolver *r)
 void Client::start_request(const Request &r)
 {
        if(request)
-               throw client_busy();
+               throw invalid_state("already processing a request");
 
        delete sock;
        sock = 0;
index d617ffed6c06e023daff3fe0e2ca2c20ef2e1c1c..e0b9b64f097b62c563480e0f879b2985cb5523c2 100644 (file)
 namespace Msp {
 namespace Http {
 
-class client_busy: public std::logic_error
-{
-public:
-       client_busy(): std::logic_error(std::string()) { }
-};
-
 class Request;
 class Response;
 
index 62521ee8926346fed24dabccc9a7af3189efff39..575ec84e6c3a0f2be7ea77039041a52b919c069d 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef MSP_NET_COMMUNICATOR_H_
 #define MSP_NET_COMMUNICATOR_H_
 
+#include <msp/core/except.h>
 #include <sigc++/signal.h>
 #include "protocol.h"
 
@@ -9,10 +10,10 @@ namespace Net {
 
 class StreamSocket;
 
-class sequence_error: public std::logic_error
+class sequence_error: public invalid_state
 {
 public:
-       sequence_error(const std::string &w): std::logic_error(w) { }
+       sequence_error(const std::string &w): invalid_state(w) { }
 };
 
 class incompatible_protocol: public std::runtime_error
index 051ac50574039d9fc1c2e407b9b791e345cb7a54..01fa445f41095e557995247fb265e3567116cb35 100644 (file)
@@ -1,3 +1,4 @@
+#include <msp/core/except.h>
 #include "serversocket.h"
 
 using namespace std;
@@ -11,12 +12,12 @@ ServerSocket::ServerSocket(Family af, int type, int proto):
 
 size_t ServerSocket::do_write(const char *, size_t)
 {
-       throw logic_error("can't write to ServerSocket");
+       throw unsupported("ServerSocket::write");
 }
 
 size_t ServerSocket::do_read(char *, size_t)
 {
-       throw logic_error("can't read from ServerSocket");
+       throw unsupported("ServerSocket::read");
 }
 
 } // namespace Net
index 85cc9872a0df0a802555e80e63df446a8f568fc8..9fd468ef84111175c620dc216932c1c387bbac26 100644 (file)
@@ -60,7 +60,7 @@ void Socket::set_inherit(bool i)
 const IO::Handle &Socket::get_handle(IO::Mode)
 {
        // TODO could this be implemented somehow?
-       throw logic_error("Socket::get_handle");
+       throw unsupported("Socket::get_handle");
 }
 
 const IO::Handle &Socket::get_event_handle()
index a3823ee44d777d008a3454ee0d76e4d90cac7d42..2e736e9a21d04ffaac1f77a704ae50f3f4ed056b 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef MSP_NET_SOCKET_H_
 #define MSP_NET_SOCKET_H_
 
+#include <msp/core/except.h>
 #include <msp/io/eventobject.h>
 #include <msp/io/handle.h>
 #include "constants.h"
 namespace Msp {
 namespace Net {
 
-class bad_socket_state: public std::logic_error
+class bad_socket_state: public invalid_state
 {
 public:
-       bad_socket_state(const std::string &w): std::logic_error(w) { }
+       bad_socket_state(const std::string &w): invalid_state(w) { }
 };
 
 
index 6bb34361584e773b38fa8309cb84c2e3eca365bd..0e88c2c2d0bc6cf1afe1f19af7f84f3ef6587690 100644 (file)
@@ -25,7 +25,7 @@ UnixAddr::UnixAddr(const string &p, bool a):
        abstract(a)
 {
        if(sizeof(sa_family_t)+path.size()+1>sizeof(sockaddr_storage))
-               throw invalid_argument("UnixAddr");
+               throw invalid_argument("UnixAddr::UnixAddr");
 }
 
 SockAddr::SysAddr UnixAddr::to_sys() const
index 2aa885708da84efb9c33afde5b4e5fa0639fdcb3..052710e8363eaa932962c82ab7ee22269aeebbb0 100644 (file)
@@ -1,4 +1,4 @@
-#include <stdexcept>
+#include <msp/core/except.h>
 #include "platform_api.h"
 #include "sockaddr_private.h"
 #include "unix.h"
@@ -11,7 +11,7 @@ namespace Net {
 UnixAddr::UnixAddr(const SysAddr &):
        abstract(false)
 {
-       throw logic_error("AF_UNIX not supported");
+       throw unsupported("AF_UNIX");
 }
 
 UnixAddr::UnixAddr(const string &p, bool a):
@@ -22,7 +22,7 @@ UnixAddr::UnixAddr(const string &p, bool a):
 
 SockAddr::SysAddr UnixAddr::to_sys() const
 {
-       throw logic_error("AF_UNIX not supported");
+       throw unsupported("AF_UNIX");
 }
 
 } // namespace Net