diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ea7a22c530..29ee6fea920 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Bugfix: Fixed crashes that could occur when Lua functions errored with values other than strings. (#6441) - Bugfix: Fixed zero-width global BTTV emotes not showing in the `:~` completions. (#6440) - Bugfix: Fixed an issue where the update button would be unclickable on macOS and Linux. (#6447) +- Bugfix: Fixed Lua errors from handlers of HTTP requests not being logged. (#6452) ## 2.5.4-beta.1 diff --git a/src/controllers/plugins/api/HTTPRequest.cpp b/src/controllers/plugins/api/HTTPRequest.cpp index 9b4d45e9e11..44344e5a527 100644 --- a/src/controllers/plugins/api/HTTPRequest.cpp +++ b/src/controllers/plugins/api/HTTPRequest.cpp @@ -115,10 +115,9 @@ void HTTPRequest::execute(sol::this_state L) auto hack = this->weak_from_this(); auto *pl = getApp()->getPlugins()->getPluginByStatePtr(L); pl->httpRequests.push_back(this->shared_from_this()); - auto *mainState = pl->state().lua_state(); std::move(this->req_) - .onSuccess([hack](const NetworkResult &res) { + .onSuccess([pl, hack](const NetworkResult &res) { auto self = hack.lock(); if (!self) { @@ -128,10 +127,12 @@ void HTTPRequest::execute(sol::this_state L) { return; } - (*self->cbSuccess)(HTTPResponse(res)); + + loggedVoidCall(*self->cbSuccess, u"HTTPRequest::on_success", pl, + HTTPResponse(res)); self->cbSuccess = std::nullopt; }) - .onError([hack](const NetworkResult &res) { + .onError([pl, hack](const NetworkResult &res) { auto self = hack.lock(); if (!self) { @@ -141,17 +142,17 @@ void HTTPRequest::execute(sol::this_state L) { return; } - (*self->cbError)(HTTPResponse(res)); + loggedVoidCall(*self->cbError, u"HTTPRequest::on_error", pl, + HTTPResponse(res)); self->cbError = std::nullopt; }) - .finally([mainState, hack]() { + .finally([pl, hack]() { auto self = hack.lock(); if (!self) { // this could happen if the plugin was deleted return; } - auto *pl = getApp()->getPlugins()->getPluginByStatePtr(mainState); for (auto it = pl->httpRequests.begin(); it < pl->httpRequests.end(); it++) { @@ -166,7 +167,7 @@ void HTTPRequest::execute(sol::this_state L) { return; } - (*self->cbFinally)(); + loggedVoidCall(*self->cbFinally, u"HTTPRequest::finally", pl); self->cbFinally = std::nullopt; }) .timeout(this->timeout_)