summaryrefslogtreecommitdiff
path: root/bot/src
diff options
context:
space:
mode:
Diffstat (limited to 'bot/src')
-rw-r--r--bot/src/commands/response_error.hpp15
-rw-r--r--bot/src/handlers.cpp9
-rw-r--r--bot/src/localization/line_id.cpp2
-rw-r--r--bot/src/localization/line_id.hpp1
4 files changed, 16 insertions, 11 deletions
diff --git a/bot/src/commands/response_error.hpp b/bot/src/commands/response_error.hpp
index ae2c3ee..b89d38e 100644
--- a/bot/src/commands/response_error.hpp
+++ b/bot/src/commands/response_error.hpp
@@ -7,6 +7,7 @@
#include <vector>
#include "command.hpp"
+#include "localization/line_id.hpp"
#include "request.hpp"
namespace bot {
@@ -23,7 +24,9 @@ namespace bot {
EXTERNAL_API_ERROR,
INSUFFICIENT_RIGHTS,
- ILLEGAL_COMMAND
+ ILLEGAL_COMMAND,
+
+ LUA_EXECUTION_ERROR
};
template <ResponseError T, class Enable = void>
@@ -31,9 +34,10 @@ namespace bot {
template <ResponseError T>
class ResponseException<
- T, typename std::enable_if<
- T == INCORRECT_ARGUMENT || T == INCOMPATIBLE_NAME ||
- T == NAMESAKE_CREATION || T == NOT_FOUND>::type>
+ T, typename std::enable_if<T == INCORRECT_ARGUMENT ||
+ T == INCOMPATIBLE_NAME ||
+ T == NAMESAKE_CREATION || T == NOT_FOUND ||
+ T == LUA_EXECUTION_ERROR>::type>
: public std::exception {
public:
ResponseException(const command::Request &request,
@@ -58,6 +62,9 @@ namespace bot {
case NOT_FOUND:
line_id = loc::LineId::ErrorNotFound;
break;
+ case LUA_EXECUTION_ERROR:
+ line_id = loc::LineId::ErrorLuaExecutionError;
+ break;
default:
line_id = loc::LineId::ErrorSomethingWentWrong;
break;
diff --git a/bot/src/handlers.cpp b/bot/src/handlers.cpp
index fe8c73c..42e1090 100644
--- a/bot/src/handlers.cpp
+++ b/bot/src/handlers.cpp
@@ -12,6 +12,7 @@
#include "commands/command.hpp"
#include "commands/request.hpp"
#include "commands/request_util.hpp"
+#include "commands/response_error.hpp"
#include "constants.hpp"
#include "cpr/api.h"
#include "cpr/multipart.h"
@@ -55,13 +56,7 @@ namespace bot::handlers {
return;
}
} catch (const std::exception &e) {
- std::string line =
- bundle.localization
- .get_formatted_line(request.value(),
- loc::LineId::ErrorSomethingWentWrong, {})
- .value();
-
- bundle.irc_client.say(message.source.login, line);
+ bundle.irc_client.say(message.source.login, e.what());
log::error("PrivMsg/" + request->command_id, e.what());
}
}
diff --git a/bot/src/localization/line_id.cpp b/bot/src/localization/line_id.cpp
index 7f17378..7382d91 100644
--- a/bot/src/localization/line_id.cpp
+++ b/bot/src/localization/line_id.cpp
@@ -48,6 +48,8 @@ namespace bot {
return LineId::ErrorInsufficientRights;
} else if (str == "error.illegal_command") {
return LineId::ErrorIllegalCommand;
+ } else if (str == "error.lua_execution_error") {
+ return LineId::ErrorLuaExecutionError;
}
else if (str == "event.on") {
diff --git a/bot/src/localization/line_id.hpp b/bot/src/localization/line_id.hpp
index e9b90c0..bc84074 100644
--- a/bot/src/localization/line_id.hpp
+++ b/bot/src/localization/line_id.hpp
@@ -26,6 +26,7 @@ namespace bot {
ErrorExternalAPIError,
ErrorInsufficientRights,
ErrorIllegalCommand,
+ ErrorLuaExecutionError,
PingResponse,