From 4cc618566d8546a06da0974612d08df80c45db62 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sat, 11 May 2024 16:31:21 +0500 Subject: feat: new response exception - illegal_command --- src/commands/response_error.hpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src/commands/response_error.hpp') diff --git a/src/commands/response_error.hpp b/src/commands/response_error.hpp index b57deea..e91a4fd 100644 --- a/src/commands/response_error.hpp +++ b/src/commands/response_error.hpp @@ -22,7 +22,9 @@ namespace bot { SOMETHING_WENT_WRONG, EXTERNAL_API_ERROR, - INSUFFICIENT_RIGHTS + INSUFFICIENT_RIGHTS, + + ILLEGAL_COMMAND }; template @@ -79,9 +81,10 @@ namespace bot { }; template - class ResponseException< - T, typename std::enable_if::type> + class ResponseException::type> : public std::exception { public: ResponseException(const command::Request &request, @@ -89,10 +92,16 @@ namespace bot { : request(request), localizator(localizator), error(T) { loc::LineId line_id; - if (this->error == INSUFFICIENT_RIGHTS) { - line_id = loc::LineId::ErrorInsufficientRights; - } else { - line_id = loc::LineId::ErrorSomethingWentWrong; + switch (this->error) { + case INSUFFICIENT_RIGHTS: + line_id = loc::LineId::ErrorInsufficientRights; + break; + case ILLEGAL_COMMAND: + line_id = loc::LineId::ErrorIllegalCommand; + break; + default: + line_id = loc::LineId::ErrorSomethingWentWrong; + break; } this->line = -- cgit v1.2.3