Skip to content

Conversation

Nerixyz
Copy link
Contributor

@Nerixyz Nerixyz commented Sep 6, 2025

When an error occurred in a handler for an HTTP request, it wasn't printed to the console or the REPL (linked issue).
With this PR, the error is printed.

To test this, you can try the code from #6224 (comment) - it should only print "finally" in the chat. It should (with this PR) print an error like chatterino.lua: [test:Test plugin] HTTPRequest::on_error - (path): attempt to concatenate a nil value in both the Chatterino log as well the REPL. Before this, there was no output.

Fixes #6224.

self->cbError = std::nullopt;
})
.finally([mainState, hack]() {
.finally([pl, hack]() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: we can just pass the plugin pointer here, because the plugin owns hack (see line 117).

I think, in the future, we could have some more generic plugin handle that we could store here (the plugin shouldn't need to know that HTTP requests exist). We can't put the plugin in a std::shared_ptr itself, but we could make the plugin own some shared pointer. That's for the next release, though.

@pajlada pajlada requested a review from Mm2PL September 7, 2025 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lua HTTPRequest fails to report callbacks' errors
2 participants