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

Update CombinedError API to expose the combinedError record as the core module type t. #109

Merged
merged 2 commits into from
Oct 5, 2019

Conversation

parkerziegler
Copy link
Contributor

Fix #106

This PR updates our CombinedError API to pass the combinedError record as the module type t that users will interact with. This feels more ergonomic to me and I believe @Schmavery felt the same. I also added the beginnings of docs on how to use CombinedError. I decided it wasn't useful to add a .rei file for this module b/c it is full of a bunch of BuckleScript accessors generated by all the [@bs.deriving abstract], and we basically want the entirety of the module public anyway.

In terms of how we want to release this, I'm a little torn. It is a small breaking change that will (I suspect) break folks' builds, but it also feels fairly minimal. I'm inclined to release it as a minor (v1.1.0) but could also consider a patch (v1.0.2) if others feel that works better. cc/ @Schmavery @gugahoa let me know your thoughts here. @Schmavery I co-authored you on the commit by the way, since I slightly modified the error modifier you have on Coda for the example here (it's really nice btw, love it).

docs/api.md Outdated

Due to the verbosity of the above, sometimes it isn't useful to handle every potential case around errors in your application. When you just want a simple error message of what went wrong to display to the user, just access the `message` field on the `CombinedError.t`:

```reason
Copy link
Collaborator

Choose a reason for hiding this comment

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

For me this ends up being what I use 90% of the time, any thoughts on putting it before the more complex solution?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's also how I mainly handle errors in the front-end, I would also prefer if it was above the more complex way to handle errors just for the sake of it and to not confuse beginners

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, thanks for the feedback!

@Schmavery
Copy link
Collaborator

Schmavery commented Oct 4, 2019

The version doesn't make much difference to me personally, I can't imagine not upgrading either way :P

Thanks for adding the docs, it's great to have something for that. Thanks for checking out the coda code :) though ironically writing code like that is replaced easily with e.message (and I actually removed that code from our codebase haha)!

I wonder if it's worth writing something that would return some different kind of react component depending on the kind of error, or in one case perform some side effect like recording a log message... I guess it doesn't matter much either way.

@parkerziegler
Copy link
Contributor Author

@Schmavery that's an interesting idea. It would be cool to handle all of the more complex parsing of graphQLErrors and networkError for users on our end at the very least. Definitely will consider this for a later release ✅

@Schmavery
Copy link
Collaborator

Sorry, I didn't mean that the library should do that sort of thing, I meant that the example could do something other than stringifying the error, since e.message is already that.

@parkerziegler
Copy link
Contributor Author

I think that'd be a worthwhile example to show. I'm considering starting an faq.md for this kind of thing – more difficult interesting / sophisticated examples with common edge cases that people have run into. I think that'd be a great place so that we keep this api.md focused on the low-level API.

@parkerziegler parkerziegler merged commit cdc4c25 into master Oct 5, 2019
@parkerziegler parkerziegler deleted the task/update-combined-error-api branch October 5, 2019 16:24
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.

Update API documentation on CombinedError.
3 participants