diff --git a/includes/exceptions/exceptions.hpp b/includes/exceptions/exceptions.hpp index 43b09ad..029cba6 100644 --- a/includes/exceptions/exceptions.hpp +++ b/includes/exceptions/exceptions.hpp @@ -21,9 +21,7 @@ # define ERR_BAD_CHAN_MASK(channel) (channel) + " :Bad Channel Mask" # define ERR_NO_SUCH_CHANNEL(channelName) (channelName) + " :No such channel" # define ERR_TOO_MANY_CHANNELS(channelName) (channelName) + " :You have joined too many channels" - # define ERR_NOT_ON_CHANNEL(channel) (channel) + " :You're not on that channel" - # define ERR_CHANOP_PRIVS_NEEDED(channel) (channel) + " :You're not channel operator" # define ERR_NO_SUCH_NICK(nickname) (nickname) + " :No such nick/channel" @@ -32,7 +30,6 @@ # define ERR_NO_RECIPIENT(command) ":No recipient given (" + (command) + ")" # define ERR_NO_TEXT_TO_SEND ":No text to send" -# define ERR_CANNOT_SEND_TO_CHAN(channel) (channel) + " :Cannot send to channel" # define ERR_KEYSET(channel) (channel) + " :Channel key already set" # define ERR_UNKOWN_MODE(modeChar) (modeChar) + " :is unknown mode char to me" @@ -212,14 +209,6 @@ class UnknownModeException : public IRCException { UnknownModeException(const std::string &modeChar) : IRCException("472", ERR_UNKOWN_MODE(modeChar)) {} }; -/** - * This exception is thrown when the user tries to send a message to a channel that does not exist. - */ -class CannotSendToChanException : public IRCException { - public: - CannotSendToChanException(const std::string &channelName) : IRCException("404", ERR_CANNOT_SEND_TO_CHAN(channelName)) {} -}; - /** * This exception is thrown when the user tries to launch an unknown command. */ diff --git a/src/commands/PrivateMessageCommand.cpp b/src/commands/PrivateMessageCommand.cpp index f18b1e7..f5158db 100644 --- a/src/commands/PrivateMessageCommand.cpp +++ b/src/commands/PrivateMessageCommand.cpp @@ -25,12 +25,9 @@ void PrivateMessageCommand::execute(int clientFd) { if (this->_receivers[i][0] == '#' || this->_receivers[i][0] == '&') { Logger::debug("Sending private message to channel " + this->_receivers[i]); - if (!server.channelExists(this->_receivers[i])) - throw CannotSendToChanException(this->_receivers[i]); - Channel &destinationChannel = server.getChannelByName(this->_receivers[i]); if (!destinationChannel.isUserInChannel(sender.getNickname())) - throw CannotSendToChanException(this->_receivers[i]); + throw NoSuchNickException(this->_receivers[i]); sender.sendPrivateMessageToChannel(destinationChannel, this->_message); } else { @@ -41,8 +38,6 @@ void PrivateMessageCommand::execute(int clientFd) { Logger::debug("Channel " + this->_receivers[i] + " does not exist."); } catch (const NoSuchNickException &e) { server.sendExceptionMessage(clientFd, e); - } catch (const CannotSendToChanException &e) { - server.sendExceptionMessage(clientFd, e); } } } \ No newline at end of file