So we can distinguish the errors.
int rcode;
isc::data::ConstElementPtr answer = isc::config::parseAnswer(rcode,
recv_msg);
+ // Translate known rcodes to the corresponding exceptions
+ if (rcode == 2) {
+ isc_throw(SocketRequestor::SocketAllocateError, answer->str());
+ }
+ if (rcode == 3) {
+ isc_throw(SocketRequestor::ShareError, answer->str());
+ }
+ // The unknown exceptions
if (rcode != 0) {
isc_throw(isc::config::CCSessionError,
"Error response when requesting socket: " << answer->str());
/// by a different application, the socket creator doesn't have enough
/// privileges, or for some kind of similar reason.
class SocketAllocateError : public NonFatalSocketError {
+ public:
SocketAllocateError(const char* file, size_t line, const char* what) :
NonFatalSocketError(file, line, what)
{ }
}
// Send back an error response
+ // A generic one first
session.getMessages()->add(createAnswer(1, "error"));
ASSERT_THROW(doRequest(), CCSessionError);
+ // Now some with specific exceptions
+ session.getMessages()->add(createAnswer(2, "error"));
+ ASSERT_THROW(doRequest(), SocketRequestor::SocketAllocateError);
+ session.getMessages()->add(createAnswer(3, "error"));
+ ASSERT_THROW(doRequest(), SocketRequestor::ShareError);
}
// Helper function to create the release commands as we expect