summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--localization/english.json1
-rw-r--r--localization/russian.json1
-rw-r--r--src/commands/response_error.hpp25
-rw-r--r--src/localization/line_id.cpp2
-rw-r--r--src/localization/line_id.hpp1
5 files changed, 22 insertions, 8 deletions
diff --git a/localization/english.json b/localization/english.json
index 1ef48cb..e48ac2e 100644
--- a/localization/english.json
+++ b/localization/english.json
@@ -18,6 +18,7 @@
"error.something_went_wrong": "Something went wrong",
"error.external_api_error": "External API error (%s%s)",
"error.insufficient_rights": "Insufficient rights",
+ "error.illegal_command": "Command not available",
"ping.response": "{sender.alias_name}: funnywhitecat Pong! %s Uptime: %s · Used memory: %sMB",
diff --git a/localization/russian.json b/localization/russian.json
index aee1bc4..0e803fe 100644
--- a/localization/russian.json
+++ b/localization/russian.json
@@ -18,6 +18,7 @@
"error.something_went_wrong": "Что-то пошло не так",
"error.external_api_error": "Ошибка стороннего API (%s%s)",
"error.insufficient_rights": "Недостаточно прав",
+ "error.illegal_command": "Команда недоступна",
"ping.response": "{sender.alias_name}: funnywhitecat Понг! %s Время сессии: %s · ОЗУ: %sМБ",
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 <ResponseError T, class Enable = void>
@@ -79,9 +81,10 @@ namespace bot {
};
template <ResponseError T>
- class ResponseException<
- T, typename std::enable_if<T == SOMETHING_WENT_WRONG ||
- T == INSUFFICIENT_RIGHTS>::type>
+ class ResponseException<T,
+ typename std::enable_if<T == SOMETHING_WENT_WRONG ||
+ T == INSUFFICIENT_RIGHTS ||
+ T == ILLEGAL_COMMAND>::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 =
diff --git a/src/localization/line_id.cpp b/src/localization/line_id.cpp
index 82441fc..4e84b16 100644
--- a/src/localization/line_id.cpp
+++ b/src/localization/line_id.cpp
@@ -46,6 +46,8 @@ namespace bot {
return LineId::ErrorSomethingWentWrong;
} else if (str == "error.insufficient_rights") {
return LineId::ErrorInsufficientRights;
+ } else if (str == "error.illegal_command") {
+ return LineId::ErrorIllegalCommand;
}
else if (str == "event.on") {
diff --git a/src/localization/line_id.hpp b/src/localization/line_id.hpp
index e820559..25ab255 100644
--- a/src/localization/line_id.hpp
+++ b/src/localization/line_id.hpp
@@ -25,6 +25,7 @@ namespace bot {
ErrorSomethingWentWrong,
ErrorExternalAPIError,
ErrorInsufficientRights,
+ ErrorIllegalCommand,
PingResponse,