fix(plugins): Log potential errors in HTTP request callbacks (#6452)
Reviewed-by: Mm2PL <mm2pl+gh@kotmisia.pl> Reviewed-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
- Bugfix: Fixed font change not resulting in forced layout update. (#6536)
|
- Bugfix: Fixed font change not resulting in forced layout update. (#6536)
|
||||||
- Bugfix: Fixed scrollbar rect computation potentially resulting in overflows. (#6547)
|
- Bugfix: Fixed scrollbar rect computation potentially resulting in overflows. (#6547)
|
||||||
- Bugfix: Forward query params to websocket URLs. (#6141)
|
- Bugfix: Forward query params to websocket URLs. (#6141)
|
||||||
|
- Bugfix: Fixed Lua errors from handlers of HTTP requests not being logged. (#6452)
|
||||||
- Dev: Update release documentation. (#6498)
|
- Dev: Update release documentation. (#6498)
|
||||||
- Dev: Make code sanitizers opt in with the `CHATTERINO_SANITIZER_SUPPORT` CMake option. After that's enabled, use the `SANITIZE_*` flag to enable individual sanitizers. (#6493)
|
- Dev: Make code sanitizers opt in with the `CHATTERINO_SANITIZER_SUPPORT` CMake option. After that's enabled, use the `SANITIZE_*` flag to enable individual sanitizers. (#6493)
|
||||||
- Dev: Remove unused QTextCodec includes. (#6487)
|
- Dev: Remove unused QTextCodec includes. (#6487)
|
||||||
|
|||||||
@@ -115,10 +115,9 @@ void HTTPRequest::execute(sol::this_state L)
|
|||||||
auto hack = this->weak_from_this();
|
auto hack = this->weak_from_this();
|
||||||
auto *pl = getApp()->getPlugins()->getPluginByStatePtr(L);
|
auto *pl = getApp()->getPlugins()->getPluginByStatePtr(L);
|
||||||
pl->httpRequests.push_back(this->shared_from_this());
|
pl->httpRequests.push_back(this->shared_from_this());
|
||||||
auto *mainState = pl->state().lua_state();
|
|
||||||
|
|
||||||
std::move(this->req_)
|
std::move(this->req_)
|
||||||
.onSuccess([hack](const NetworkResult &res) {
|
.onSuccess([pl, hack](const NetworkResult &res) {
|
||||||
auto self = hack.lock();
|
auto self = hack.lock();
|
||||||
if (!self)
|
if (!self)
|
||||||
{
|
{
|
||||||
@@ -128,10 +127,12 @@ void HTTPRequest::execute(sol::this_state L)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
(*self->cbSuccess)(HTTPResponse(res));
|
|
||||||
|
loggedVoidCall(*self->cbSuccess, u"HTTPRequest::on_success", pl,
|
||||||
|
HTTPResponse(res));
|
||||||
self->cbSuccess = std::nullopt;
|
self->cbSuccess = std::nullopt;
|
||||||
})
|
})
|
||||||
.onError([hack](const NetworkResult &res) {
|
.onError([pl, hack](const NetworkResult &res) {
|
||||||
auto self = hack.lock();
|
auto self = hack.lock();
|
||||||
if (!self)
|
if (!self)
|
||||||
{
|
{
|
||||||
@@ -141,17 +142,17 @@ void HTTPRequest::execute(sol::this_state L)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
(*self->cbError)(HTTPResponse(res));
|
loggedVoidCall(*self->cbError, u"HTTPRequest::on_error", pl,
|
||||||
|
HTTPResponse(res));
|
||||||
self->cbError = std::nullopt;
|
self->cbError = std::nullopt;
|
||||||
})
|
})
|
||||||
.finally([mainState, hack]() {
|
.finally([pl, hack]() {
|
||||||
auto self = hack.lock();
|
auto self = hack.lock();
|
||||||
if (!self)
|
if (!self)
|
||||||
{
|
{
|
||||||
// this could happen if the plugin was deleted
|
// this could happen if the plugin was deleted
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto *pl = getApp()->getPlugins()->getPluginByStatePtr(mainState);
|
|
||||||
for (auto it = pl->httpRequests.begin();
|
for (auto it = pl->httpRequests.begin();
|
||||||
it < pl->httpRequests.end(); it++)
|
it < pl->httpRequests.end(); it++)
|
||||||
{
|
{
|
||||||
@@ -166,7 +167,7 @@ void HTTPRequest::execute(sol::this_state L)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
(*self->cbFinally)();
|
loggedVoidCall(*self->cbFinally, u"HTTPRequest::finally", pl);
|
||||||
self->cbFinally = std::nullopt;
|
self->cbFinally = std::nullopt;
|
||||||
})
|
})
|
||||||
.timeout(this->timeout_)
|
.timeout(this->timeout_)
|
||||||
|
|||||||
Reference in New Issue
Block a user