From: Michal 'vorner' Vaner Date: Thu, 26 Jan 2012 15:20:27 +0000 (+0100) Subject: [1542] Define the exceptions X-Git-Tag: trac2351_base~273^2~12 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5d3ea6cbda70b4ffeb278fdd8aa3c3a84750e580;p=thirdparty%2Fkea.git [1542] Define the exceptions --- diff --git a/src/lib/server_common/socket_request.h b/src/lib/server_common/socket_request.h index b67c66ac29..7398ee7d84 100644 --- a/src/lib/server_common/socket_request.h +++ b/src/lib/server_common/socket_request.h @@ -104,6 +104,50 @@ public: { } }; + /// \brief Exception when we can't return a requested socket, but we're + /// sure we could return others + /// + /// This is thrown if the requested socket can't be granted, but it is only + /// that one socket, not that the system would be broken or anything. This + /// exception is a common base class for the concrete exceptions actually + /// thrown. + /// + /// \see ShareError + /// \see SocketAllocateError + class NonFatalSocketError : public SocketError { + public: + NonFatalSocketError(const char* file, size_t line, const char* what) : + SocketError(file, line, what) + { } + }; + + /// \brief Exception when the socke is allocated by other bind10 module + /// and it doesn't want to share it. + /// + /// This is thrown if a socket is requested and the socket is already + /// allocated by bind10, but other bind10 module(s) is using it and + /// the sharing parameters are incompatible (the socket can't be shared + /// between the module and our module). + class ShareError : public NonFatalSocketError { + public: + ShareError(const char* file, size_t line, const char* what) : + NonFatalSocketError(file, line, what) + { } + }; + + /// \brief Exception when the operation system doesn't allow us to create + /// the requested socket. + /// + /// This happens when the socket() or bind() call fails in the socket + /// creator. This can happen when the address/port pair is already taken + /// by a different application, the socket creator doesn't have enough + /// privileges, or for some kind of similar reason. + class SocketAllocateError : public NonFatalSocketError { + SocketAllocateError(const char* file, size_t line, const char* what) : + NonFatalSocketError(file, line, what) + { } + }; + /// \brief Ask for a socket /// /// Asks the socket creator to give us a socket. The socket will be bound