Tribler / tribler

Privacy enhanced BitTorrent client with P2P content discovery
https://www.tribler.org
GNU General Public License v3.0
4.86k stars 451 forks source link

Forward errors to GitHub issues #8117

Closed qstokkink closed 2 months ago

qstokkink commented 2 months ago

When we have an uncaught core error, the core responds with an HTTP 500 message to the GUI. However, unless we look at the raw responses coming in (on the GUI side), we won't know of these errors.

We should let a user know that an error has occurred and allow them to forward these hidden stack traces to some error reporting facility (e.g., straight to GitHub issues).

qstokkink commented 2 months ago

It turns out that we can relatively easily forward errors to GitHub. For example:

https://github.com/Tribler/tribler/issues/new?body=Hello+World!%0AI+am+an+issue.

This link creates an issue filled with:

Hello World!
I am an issue
qstokkink commented 2 months ago

To catch the errors themselves, I think we'll have to wrap all the async http calls in TriblerService and IPv8Service in error handlers.

Getting the actual error out of the response seems like its own can of worms: https://stackoverflow.com/a/66234804

My thinking is that we can then throw any error that we caught again and then also initiate some sort of user popup (I guess from dialog.tsx) that shows the error and the available options ("search", "report" or "ignore").

The following works, but getting an alert is proving to be challenging.

        try {
            return (await this.http.get(`<<URL>>`)).data;
        } catch (error) {
            console.error(error.response.data.error.message);
            // Do something with this
            throw error;
        }

EDIT: Actually, just setting an interceptor using this.http.interceptors.response.use() should be simpler.

qstokkink commented 2 months ago

Alright, I think I'm confident enough to try and resolve this.

qstokkink commented 2 months ago

You can do some pretty fancy things with this TypeScript stuff:

recording