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

Intelligently select branches/depth to describe in union types #40

Open
osdiab opened this issue Jul 20, 2020 · 1 comment
Open

Intelligently select branches/depth to describe in union types #40

osdiab opened this issue Jul 20, 2020 · 1 comment

Comments

@osdiab
Copy link
Contributor

osdiab commented Jul 20, 2020

In combination with #38 , if this reporter could intelligently select a path to display errors for and skip errors/reporting more deeply if the message is getting overwhelmingly long - I think it would make errors easier to grok. Perhaps this truncating behavior ought to be behind a flag or exported separately for people who want full errors.

Basic example

Decode error for FeedItem: expected one of:
  - UserSuggestionFeedItem
  - UserPostFeedItem
  - PageSuggestionFeedItem
but instead got undefined.

More complex example


Decode error for FeedItem: expected one of:
  - UserSuggestionFeedItem
  - UserPostFeedItem
  - PageSuggestionFeedItem
  - { type: "GroupFeedItem", name: string, meta: { ... }, ... }
but value didn't match. Errors for closest match, UserPostFeedItem:
  - Expected number at data.numLikes but instead got: "4"
  - Expected Date at data.meta.postedAt but instead got: undefined.
  - Expected PostType at data.postType but instead got: "Omar Diab"
  ... and 4 other errors ...

Would potentially be able to be more specific for tagged types.

@gillchristian
Copy link
Owner

This looks slightly related to #37

Perhaps this truncating behavior ought to be behind a flag or exported separately for people who want full errors.

I think we could implement different reporters for the different use cases instead of having a single one with different options.

Eg. at work we use it for reporting of API validation errors, sending the reporting errors to an error aggregator. So there we need to see all the errors and is not necessary to have a pretty version. But for development something like your examples or what I suggested on #37 would be really nice.

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

No branches or pull requests

2 participants