fix(core/error_code): now commands use the correct error code

This commit is contained in:
Raphael 2025-06-05 22:56:28 +02:00
parent 8ea4da3b82
commit bc8410a21d
19 changed files with 81 additions and 77 deletions

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/20 23:31:58 by rparodi #+# #+# */
/* Updated: 2025/05/29 12:47:57 by rparodi ### ########.fr */
/* Updated: 2025/06/05 22:55:54 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
@ -17,6 +17,7 @@
#include "user.hpp"
#include "channel.hpp"
#include "server.hpp"
#include "core.hpp"
#include "logs.hpp"
namespace cmd
@ -39,7 +40,7 @@ namespace cmd
std::vector<std::string> _args;
public:
virtual void execute() = 0;
virtual bool checkArgs() = 0;
virtual e_code checkArgs() = 0;
~ACommand();
ACommand(User *user, Channel *channel, Server *server, const std::string &line);
};

View file

@ -18,5 +18,5 @@ class cmd::Invite : public ACommand {
public:
Invite(User *user, Channel *channel, Server *server, const std::string &line) : ACommand(user, channel, server, line) {}
virtual void execute(void);
virtual bool checkArgs();
virtual e_code checkArgs();
};

View file

@ -18,5 +18,5 @@ class cmd::Join : public ACommand {
public:
Join(User *user, Channel *channel, Server *server, const std::string &line) : ACommand(user, channel, server, line) {}
virtual void execute(void);
virtual bool checkArgs();
virtual e_code checkArgs();
};

View file

@ -18,5 +18,5 @@ class cmd::Nick : public ACommand {
public:
Nick(User *user, Channel *channel, Server *server, const std::string &line) : ACommand(user, channel, server, line) {}
virtual void execute(void);
virtual bool checkArgs();
virtual e_code checkArgs();
};

View file

@ -18,5 +18,5 @@ class cmd::Notice : public ACommand {
public:
Notice(User *user, Channel *channel, Server *server, const std::string &line) : ACommand(user, channel, server, line) {}
virtual void execute(void);
virtual bool checkArgs();
virtual e_code checkArgs();
};

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/24 17:17:31 by rparodi #+# #+# */
/* Updated: 2025/06/02 00:51:23 by rparodi ### ########.fr */
/* Updated: 2025/06/04 23:49:09 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
@ -18,5 +18,5 @@ class cmd::Part : public ACommand {
public:
Part(User *user, Channel *channel, Server *server, const std::string &line) : ACommand(user, channel, server, line) {}
virtual void execute(void);
virtual bool checkArgs();
virtual e_code checkArgs();
};

View file

@ -19,6 +19,6 @@ namespace cmd {
public:
Pass(User *user, Channel *channel, Server *server, const std::string &line) : ACommand(user, channel, server, line) {}
virtual void execute(void);
virtual bool checkArgs();
virtual e_code checkArgs();
};
}

View file

@ -18,5 +18,5 @@ class cmd::Ping : public ACommand {
public:
Ping(User *user, Channel *channel, Server *server, const std::string &line) : ACommand(user, channel, server, line) {}
virtual void execute(void);
virtual bool checkArgs();
virtual e_code checkArgs();
};

View file

@ -18,5 +18,5 @@ class cmd::PrivMsg : public ACommand {
public:
PrivMsg(User *user, Channel *channel, Server *server, const std::string &line) : ACommand(user, channel, server, line) {}
virtual void execute(void);
virtual bool checkArgs();
virtual e_code checkArgs();
};

View file

@ -6,7 +6,7 @@
/* By: omoudni <omoudni@student.42paris.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/12 14:16:03 by rparodi #+# #+# */
/* Updated: 2025/06/04 23:45:35 by rparodi ### ########.fr */
/* Updated: 2025/06/05 11:10:45 by rparodi ### ########.fr */
/* */
/******************************************************************************/
@ -17,6 +17,8 @@
#endif
enum e_code {
//command for parsing
_PARSING_OK = 000,
// Reply codes (RPL_*)
RPL_WELCOME = 001, // “<nick> :Welcome to the Internet Relay Network <nick>!<user>@<host>”
RPL_YOURHOST = 002, // “<nick> :Your host is <servername>, running version <ver>”
@ -153,7 +155,7 @@ enum e_code {
ERR_TOOMANYTARGETS = 407, // “<target> :Duplicate recipients. No message delivered”
ERR_NOSUCHSERVICE = 408, // “<service name> :No such service ”
ERR_NOORIGIN = 409, // “:No origin specified”
ERR_NORECIPIENT = 411, // “:No recipient given (<command>)”
ERR_NOREC = 411, // “:No recipient given (<command>)”
ERR_NOTEXTTOSEND = 412, // “:No text to send”
ERR_NOTOPLEVEL = 413, // “<mask> :No toplevel domain specified”
ERR_WILDTOPLEVEL = 414, // “<mask> :Wildcard in toplevel domain”
@ -173,7 +175,7 @@ enum e_code {
ERR_NOLOGIN = 444, // “<user> :User not logged in”
ERR_SUMMONDISABLED = 445, // “:SUMMON has been disabled”
ERR_USERSDISABLED = 446, // “:USERS has been disabled”
ERR_NOTREGISTERED = 451, // “:You have not registered”
ERR_NOTTERED = 451, // “:You have not registered”
ERR_NEEDMOREPARAMS = 461, // “<command> :Not enough parameters”
ERR_ALREADYREGISTERED = 462, // “:You may not reregister”
ERR_NOPERMFORHOST = 463, // “:Your host isn't among the privileged”