Skip to content

Remove ChainError trait #3901

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

Merged
merged 2 commits into from
Sep 20, 2021
Merged

Remove ChainError trait #3901

merged 2 commits into from
Sep 20, 2021

Conversation

Turbo87
Copy link
Member

@Turbo87 Turbo87 commented Sep 8, 2021

The chain_error() function can be replaced by ok_or_else() (for Option) or map_err() (for Result), which makes the intent a little clearer, and removes one of the layers of indirection from our error handling, without being significantly more verbose.

Please note that this only removes the ChainError trait, but the ChainedError struct still exists.

@Turbo87 Turbo87 added C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear A-backend ⚙️ labels Sep 8, 2021
@Turbo87 Turbo87 requested review from jtgeibel and 0xPoe September 10, 2021 15:22
@Turbo87 Turbo87 force-pushed the chain-error branch 3 times, most recently from 9701459 to 1b12db7 Compare September 17, 2021 21:46
For `Option` there is nothing to chain onto, so we might as well use the built-in `ok_or_else()` method to convert the `Option` to a `Result`
Using `map_err()` instead is just a few characters more, but makes it more clear how the original error is chained onto the new error
Copy link
Member

@0xPoe 0xPoe left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@Turbo87
Copy link
Member Author

Turbo87 commented Sep 20, 2021

@bors r=hi-rustin

@bors
Copy link
Contributor

bors commented Sep 20, 2021

📌 Commit 9e40742 has been approved by hi-rustin

@bors
Copy link
Contributor

bors commented Sep 20, 2021

⌛ Testing commit 9e40742 with merge 274f601...

@bors
Copy link
Contributor

bors commented Sep 20, 2021

☀️ Test successful - checks-actions
Approved by: hi-rustin
Pushing 274f601 to master...

@bors bors merged commit 274f601 into rust-lang:master Sep 20, 2021
@Turbo87 Turbo87 deleted the chain-error branch September 21, 2021 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-backend ⚙️ C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants