mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 00:31:14 +00:00
Replace exit()s with exceptions
This commit is contained in:
parent
4b516de81a
commit
b56e32eb11
|
@ -13,7 +13,8 @@
|
|||
#include <fairmq/ofi/TransportFactory.h>
|
||||
#endif
|
||||
#include <FairMQLogger.h>
|
||||
#include <fairmq/tools/Unique.h>
|
||||
#include <fairmq/Tools.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
|
@ -55,6 +56,6 @@ auto FairMQTransportFactory::CreateTransportFactory(const string& type,
|
|||
<< ", and \"ofi\""
|
||||
#endif /* BUILD_OFI_TRANSPORT */
|
||||
<< ". Exiting.";
|
||||
exit(EXIT_FAILURE);
|
||||
throw fair::mq::TransportFactoryError(fair::mq::tools::ToString("Unavailable transport requested: ", type));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,13 +9,15 @@
|
|||
#define FAIR_MQ_SHMEM_POLLER_H_
|
||||
|
||||
#include "Socket.h"
|
||||
|
||||
#include <fairmq/Tools.h>
|
||||
#include <FairMQChannel.h>
|
||||
#include <FairMQLogger.h>
|
||||
#include <FairMQPoller.h>
|
||||
|
||||
#include <zmq.h>
|
||||
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <zmq.h>
|
||||
|
||||
class FairMQChannel;
|
||||
|
||||
|
@ -101,9 +103,8 @@ class Poller final : public fair::mq::Poller
|
|||
}
|
||||
}
|
||||
} catch (const std::out_of_range& oor) {
|
||||
LOG(error) << "at least one of the provided channel keys for poller initialization is invalid";
|
||||
LOG(error) << "out of range error: " << oor.what() << '\n';
|
||||
exit(EXIT_FAILURE);
|
||||
LOG(error) << "At least one of the provided channel keys for poller initialization is invalid." << " Out of range error: " << oor.what();
|
||||
throw fair::mq::PollerError(fair::mq::tools::ToString("At least one of the provided channel keys for poller initialization is invalid. ", "Out of range error: ", oor.what()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,7 +121,7 @@ class Poller final : public fair::mq::Poller
|
|||
item.events = ZMQ_POLLIN;
|
||||
} else {
|
||||
LOG(error) << "invalid poller configuration, exiting.";
|
||||
exit(EXIT_FAILURE);
|
||||
throw fair::mq::PollerError("Invalid poller configuration, exiting.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,7 +132,7 @@ class Poller final : public fair::mq::Poller
|
|||
LOG(debug) << "polling exited, reason: " << zmq_strerror(errno);
|
||||
} else {
|
||||
LOG(error) << "polling failed, reason: " << zmq_strerror(errno);
|
||||
throw std::runtime_error("polling failed");
|
||||
throw fair::mq::PollerError(fair::mq::tools::ToString("Polling failed, reason: ", zmq_strerror(errno)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -163,9 +164,9 @@ class Poller final : public fair::mq::Poller
|
|||
|
||||
return false;
|
||||
} catch (const std::out_of_range& oor) {
|
||||
LOG(error) << "invalid channel key: \"" << channelKey << "\"";
|
||||
LOG(error) << "out of range error: " << oor.what() << '\n';
|
||||
exit(EXIT_FAILURE);
|
||||
LOG(error) << "invalid channel key: '" << channelKey << "'";
|
||||
LOG(error) << "out of range error: " << oor.what();
|
||||
throw fair::mq::PollerError(fair::mq::tools::ToString("Invalid channel key '", channelKey, "'. Out of range error: ", oor.what()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,9 +179,9 @@ class Poller final : public fair::mq::Poller
|
|||
|
||||
return false;
|
||||
} catch (const std::out_of_range& oor) {
|
||||
LOG(error) << "Invalid channel key: \"" << channelKey << "\"";
|
||||
LOG(error) << "out of range error: " << oor.what() << '\n';
|
||||
exit(EXIT_FAILURE);
|
||||
LOG(error) << "invalid channel key: '" << channelKey << "'";
|
||||
LOG(error) << "out of range error: " << oor.what();
|
||||
throw fair::mq::PollerError(fair::mq::tools::ToString("Invalid channel key '", channelKey, "'. Out of range error: ", oor.what()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#ifndef FAIR_MQ_ZMQ_POLLER_H
|
||||
#define FAIR_MQ_ZMQ_POLLER_H
|
||||
|
||||
#include <fairmq/zeromq/Socket.h>
|
||||
#include <fairmq/Tools.h>
|
||||
#include <FairMQChannel.h>
|
||||
#include <FairMQLogger.h>
|
||||
#include <FairMQPoller.h>
|
||||
|
@ -104,8 +106,8 @@ class Poller final : public fair::mq::Poller
|
|||
}
|
||||
} catch (const std::out_of_range& oor) {
|
||||
LOG(error) << "at least one of the provided channel keys for poller initialization is invalid";
|
||||
LOG(error) << "out of range error: " << oor.what() << '\n';
|
||||
throw std::out_of_range("invalid channel during poller initialization");
|
||||
LOG(error) << "out of range error: " << oor.what();
|
||||
throw fair::mq::PollerError(fair::mq::tools::ToString("At least one of the provided channel keys for poller initialization is invalid. ", "Out of range error: ", oor.what()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,7 +124,7 @@ class Poller final : public fair::mq::Poller
|
|||
item.events = ZMQ_POLLIN;
|
||||
} else {
|
||||
LOG(error) << "invalid poller configuration, exiting.";
|
||||
exit(EXIT_FAILURE);
|
||||
throw fair::mq::PollerError("Invalid poller configuration, exiting.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,7 +135,7 @@ class Poller final : public fair::mq::Poller
|
|||
LOG(debug) << "polling exited, reason: " << zmq_strerror(errno);
|
||||
} else {
|
||||
LOG(error) << "polling failed, reason: " << zmq_strerror(errno);
|
||||
throw std::runtime_error("polling failed");
|
||||
throw fair::mq::PollerError(fair::mq::tools::ToString("Polling failed, reason: ", zmq_strerror(errno)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -165,9 +167,9 @@ class Poller final : public fair::mq::Poller
|
|||
|
||||
return false;
|
||||
} catch (const std::out_of_range& oor) {
|
||||
LOG(error) << "invalid channel key: \"" << channelKey << "\"";
|
||||
LOG(error) << "out of range error: " << oor.what() << '\n';
|
||||
exit(EXIT_FAILURE);
|
||||
LOG(error) << "invalid channel key: '" << channelKey << "'";
|
||||
LOG(error) << "out of range error: " << oor.what();
|
||||
throw fair::mq::PollerError(fair::mq::tools::ToString("Invalid channel key '", channelKey, "'. Out of range error: ", oor.what()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -180,9 +182,9 @@ class Poller final : public fair::mq::Poller
|
|||
|
||||
return false;
|
||||
} catch (const std::out_of_range& oor) {
|
||||
LOG(error) << "invalid channel key: \"" << channelKey << "\"";
|
||||
LOG(error) << "out of range error: " << oor.what() << '\n';
|
||||
exit(EXIT_FAILURE);
|
||||
LOG(error) << "invalid channel key: '" << channelKey << "'";
|
||||
LOG(error) << "out of range error: " << oor.what();
|
||||
throw fair::mq::PollerError(fair::mq::tools::ToString("Invalid channel key '", channelKey, "'. Out of range error: ", oor.what()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ class Socket final : public fair::mq::Socket
|
|||
{
|
||||
if (fSocket == nullptr) {
|
||||
LOG(error) << "Failed creating socket " << fId << ", reason: " << zmq_strerror(errno);
|
||||
exit(EXIT_FAILURE);
|
||||
throw SocketError(tools::ToString("Unavailable transport requested: ", type));
|
||||
}
|
||||
|
||||
if (zmq_setsockopt(fSocket, ZMQ_IDENTITY, fId.c_str(), fId.length()) != 0) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user