Skip to content

Conversation

@mediaminister
Copy link
Collaborator

Trying to provide error messages in Kodi GUI for all network problems improving #385

@mediaminister mediaminister added the enhancement New feature or request label Jun 29, 2020
@mediaminister mediaminister added this to the v2.4.0 milestone Jun 29, 2020
@mediaminister mediaminister force-pushed the errors branch 5 times, most recently from adca18f to c2d175e Compare July 3, 2020 09:35
@dagwieers
Copy link
Collaborator

dagwieers commented Jul 3, 2020

I am not convinced we want to add a failmessage to the URL-accessing function, it somehow feels too limited or unneeded. So (without having looked at what would be needed to cover this, enlighten me ;-)). We probably can describe 2 kind of issues:

  • Issues that does not require specific context (all kinds of connection issues, potentially some HTTP errors, like 401)
  • Issues that require specific error messages because they provide context (and potentially resolution)

For the first set of issues, I think we can get away with generic error handling and messages. The cause/resolution can also be generally be applied. This would either be caught using exception-handling, or testing HTTP error code within the calling function.

For the second set of issues, usually HTTP errors, there may be different courses of action:

  • It may require (a slightly different) retry or alternative workaround to continue without escalating to the user
  • There could be different errors requiring different resolution/message, so a single failmessage feels too limited

Could we instead raise HTTP errors as exceptions, and leave the handling/error message up to the exception-handling? This would allow both actions or escalation to the user. The interface could then simply consist of a list of HTTP errors that are caught in the calling code, and our URL-handling code would simply fall back to generic handling unless told otherwise.

So instead of failmessage= we could have raise_errors=[400, 413, 415, 431] and those would then be exposed as CustomHTTPError(XXX).

@mediaminister mediaminister force-pushed the errors branch 4 times, most recently from febe9f0 to 01000ae Compare July 3, 2020 11:46
@mediaminister
Copy link
Collaborator Author

I removed failmessage and implemented the raise_errors list. Raising the HTTPError again if the exc.code is in the raise_errors list works fine. I think there is no need for a CustomHTTPError.

Currently the raise_errors list is only used in Tokenresolver._get_fresh_token

@dagwieers
Copy link
Collaborator

Raising the HTTPError again if the exc.code is in the raise_errors list works fine. I think there is no need for a CustomHTTPError.

I wasn't sure if a custom exception would be easier to catch and select the exact error caught in a single catch-statement. So we could have a catch-statement per error-case. But that would require a custom exception per HTTP error I guess...

Copy link
Collaborator

@dagwieers dagwieers left a comment

Choose a reason for hiding this comment

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

I like this implementation. The connection errors I would like to make more specific (we have quite a few specific ones listed in #385), which would mean the error messages could give more context. But merging this as a first version would be perfect.

Once we release this as part of v2.4.0 I think we need to ask our users to report any generic add-on errors (those that are not caught) or send us feedback on issues that do not match with the error statement so we can further refine error handling.

Another approach would be to handle any uncaught exception from the root and provide a generic error to report this error to us with full debug log. I am not sure if that is a good approach in general for the majority of our users. Some add-ons (e.g. Netflix) have this as an option.

@dagwieers
Copy link
Collaborator

dagwieers commented Jul 3, 2020

Thinking about this further, having this part of a more common framework for all add-ons to reuse would be really useful too.

cc @michaelarnauts

@mediaminister mediaminister force-pushed the errors branch 7 times, most recently from b1d3e06 to 74cce34 Compare July 3, 2020 15:33
@mediaminister mediaminister marked this pull request as ready for review July 3, 2020 16:05
@mediaminister
Copy link
Collaborator Author

But merging this as a first version would be perfect.

Feel free to merge this. I tested this and it works fine. Kodi add-on errors shouldn't happen anymore. Refining the error messages is something we can do one by one as they happen.

@dagwieers dagwieers merged commit 8c8edcd into add-ons:master Jul 5, 2020
@mediaminister mediaminister deleted the errors branch January 21, 2022 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants