0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-29 12:18:54 +02:00

ircd::chan: Add some basic protocol ERR exceptions.

This commit is contained in:
Jason Volk 2016-08-20 00:06:41 -07:00
parent 68b8a83419
commit 9a22cfd393
3 changed files with 10 additions and 10 deletions

View file

@ -31,10 +31,10 @@
namespace ircd { namespace ircd {
namespace chan { namespace chan {
IRCD_EXCEPTION(ircd::error, error) IRCD_EXCEPTION(ircd::error, error)
IRCD_EXCEPTION(error, not_found) IRCD_EXCEPTION(error, not_found)
IRCD_EXCEPTION(error, invalid_list) IRCD_EXCEPTION(error, invalid_argument)
IRCD_EXCEPTION(error, invalid_argument) IRCD_EXCEPTION(invalid_argument, invalid_list)
enum status enum status
{ {

View file

@ -133,7 +133,7 @@ struct name \
* *
* IRCD_EXCEPTION(ircd::error, error) * IRCD_EXCEPTION(ircd::error, error)
*/ */
IRCD_EXCEPTION(exception, error) // throw ircd::error("something bad") IRCD_EXCEPTION(exception, error) // throw ircd::error("something bad")
} // namespace ircd } // namespace ircd
#endif // __cplusplus #endif // __cplusplus

View file

@ -58,7 +58,7 @@ chan::add(const std::string &name,
client &client) client &client)
{ {
if (name.empty()) if (name.empty())
throw invalid_argument(); throw err::BADCHANNAME("");
if (name.size() > CHANNELLEN && IsServer(&client)) if (name.size() > CHANNELLEN && IsServer(&client))
sendto_realops_snomask(SNO_DEBUG, L_ALL, sendto_realops_snomask(SNO_DEBUG, L_ALL,
@ -69,7 +69,7 @@ chan::add(const std::string &name,
name.c_str()); name.c_str());
if (name.size() > CHANNELLEN) if (name.size() > CHANNELLEN)
throw invalid_argument(); throw err::BADCHANNAME(name.c_str());
const auto it(chans.lower_bound(&name)); const auto it(chans.lower_bound(&name));
if (it != end(chans)) if (it != end(chans))
@ -93,7 +93,7 @@ try
} }
catch(const std::out_of_range &e) catch(const std::out_of_range &e)
{ {
throw not_found(); throw err::NOSUCHCHANNEL(name.c_str());
} }
chan::chan * chan::chan *
@ -315,7 +315,7 @@ chan::get(members &members,
const auto key(const_cast<ircd::chan::client *>(&client)); //TODO: temp elaborated const auto key(const_cast<ircd::chan::client *>(&client)); //TODO: temp elaborated
const auto it(members.global.find(key)); const auto it(members.global.find(key));
if (it == end(members.global)) if (it == end(members.global))
throw not_found(); throw err::NOTONCHANNEL(client.name);
return it->second; return it->second;
} }
@ -330,7 +330,7 @@ chan::get(const members &members,
const auto key(const_cast<ircd::chan::client *>(&client)); //TODO: temp elaborated const auto key(const_cast<ircd::chan::client *>(&client)); //TODO: temp elaborated
const auto it(members.global.find(key)); const auto it(members.global.find(key));
if (it == end(members.global)) if (it == end(members.global))
throw not_found(); throw err::NOTONCHANNEL(client.name);
return it->second; return it->second;
} }