Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/improve serde error handling #645

Merged
merged 6 commits into from
Mar 8, 2024

Conversation

elpiel
Copy link
Member

@elpiel elpiel commented Mar 1, 2024

  • Introduce additional details in Addons' ResourceResponse when deserialization fails

  • Introduce serde_path_to_error which, if addon returns a badly formatted JSON, will result in a clear error where the mistake is located
    NB: On items inside each of the different response types we still skip any item which is not deserializable (e.g. missing a mandatory field)

  • Refactor APIResult to use tagged enum variant (related to API change https://github.com/Stremio/stremio-api/pull/184, error is no longer set if it's null)
    Given a bad response of {"unknown_variant": {"test": 1}}
    When APIResult does not match any variant it returns a vary vague error:
    data did not match any variant of untagged enum APIResult

with this change we now return a much cleaner and well understood error:
unknown variant `unknown_variant`, expected `error` or `result` at line 1 column 18

@elpiel elpiel requested review from Ivshti, nklhtv and tymmesyde March 5, 2024 17:38
@elpiel elpiel marked this pull request as ready for review March 5, 2024 18:16
@elpiel elpiel merged commit db0800f into development Mar 8, 2024
2 checks passed
@elpiel elpiel deleted the feat/improve-serde-error-handling branch March 8, 2024 09:49
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.

3 participants