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
Use error-chain #21
Comments
Could you perhaps give a few examples of places where we return an |
Line 72 in 5926b66
Line 81 in 5926b66
These are lines where you'd just call unwrap() on the result. This is usually considered "bad style".
Lines 37 to 41 in 5926b66
You even wrote a comment for that one. My suggestion is to simply wrap every call that could probably fail with an error message to produce a Result<T>
|
The first two examples you've given should call You need to remember that In the case of the third example - yes, it should return a |
The documentation is wrong then. createElement can throw exceptions if the tag name is not valid. |
The MDN explicitly says that:
So it either returns a concrete element, or HTMLUnknownElement if it isn't recognized. If the docs are wrong (and they might) and the function actually can result in an exception then yes, it should return a [edit] |
Yeah I'm usually really tempted to look at the MDN as well, so 🤷♂️ 😁 |
Well, if you feel like it then I would quite welcome any changes which fix places which currently don't return a As for the |
error-chain is super heavy weight. I'd go for quick-error, derive-error or something simpler like that. error-chain brings a ton of non-portable garbage with it by default (e.g. the backtrace dependency) |
Yep. Which is if we'd have support for it I would absolutely want it to be optional. |
I admit, error-chain is not the lightest crate. But I think we should use some kind of error handling crate |
What about failure? |
It seems the community trend is moving from error-chain towards failure at the moment. It's owned by a Mozillian and appears intended to replace things like error-chain. |
I recognized that a most parts of the api either
panic!
or return anOption<T>
.Option<T>
should only be used when there legitimately might be nothing to return. In any other case I would suggest to use theResult<T>
that theerror-chain
crate offers.I wouldn't use the actual chaining feature of the crate in tight loops as this can lead to severe performance issues.
I would like to implement this myself if it is a wanted feature. The
error-chain
crate also is very well maintained and already found a good adoption rate in the Rust community.The text was updated successfully, but these errors were encountered: