-
Notifications
You must be signed in to change notification settings - Fork 108
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
Improve Errors #152
Improve Errors #152
Conversation
src/lib.rs
Outdated
pub struct NodeNotFoundError(pub node::Node); | ||
|
||
#[cfg(feature = "std")] | ||
impl Display for NodeNotFoundError { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should just pull in thiserror
and feature-gate it behind std
. It's a much nicer way to define these error strings.
src/lib.rs
Outdated
child_count: usize, | ||
}, | ||
///The [`Node`](node::Node) was not found in the [`Taffy`] instance | ||
NodeNotFoundError(NodeNotFoundError), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't love nesting these errors like this, but until we have "enum variants are types" this is a better design to keep the function signatures of most of the operations cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! First round of feedback is up :) Some suggestions on naming mostly.
I'd like feedback on whether or not we should use thiserror
.
The API is much nicer, but it pulls in some relatively heavy proc-macro crates which might hurt compile times.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost ready now.
Excellent work; thanks for being so responsive to reviews. |
Thank you for being quick to provide feedback. I appreciate it |
* Added checks for child_index out of bounds * slightly better descriptions * updated RELEASES.md * Changed TaffyError back to Error * split error type into two * fixed error in git merge * updated RELEASES.md file * cargo fmt * moved errors into error module, and gave them better names * Split InvalidChild::InvalidNode into two * updated RELEASES.md * cargo fmt * more changes to RELEASES.md Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Objective
Replaces
taffy::Error
withtaffy::NodeNotFoundError
to make code much more legible. Also addstaffy::ChildOperationError
so thatremove_child_at_index
,replace_child_at_index
, andchild_at_index
can return an error instead of panicing.Fixes #100 #104
Feedback wanted
I'm not happy with the name of
ChildOperationError
. It feels a little vague to me. Is it fine, or is there possibly a better name for it?Also, I'm not sure I should have flattened NodeNotFoundError into a tuple struct.