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

handling a crate::Error example #612

Merged
merged 5 commits into from
Mar 25, 2022
Merged

Conversation

cataggar
Copy link
Member

@cataggar cataggar commented Jan 14, 2022

The current crate::Error design is still lacking documentation, so here is what I think a common use case will be. The user wants to do structured errors, but does not care about the specific error type in azure_svc_batch. This case can be handled by implementing From for Into<azure_svc_batch::Error>.

One design caveat is that all structured errors must have a From defined in the crate::Error and it should not define From implementations for errors that are not in crate.

For printing of source errors, it is important that source be defined. #611 updated core & I'll need to update the services.

Copy link
Contributor

@rylev rylev left a comment

Choose a reason for hiding this comment

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

This looks good and still fits with the proposal for errors that @yoshuawuyts and I have been working on.

}
}

fn print_error_chain(error: impl std::error::Error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We may want to add that there is ecosystem support for this. For example eyre

Copy link
Member Author

Choose a reason for hiding this comment

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

I added the eyre example code and a note.

@cataggar cataggar marked this pull request as draft January 26, 2022 15:14
@cataggar cataggar marked this pull request as ready for review March 25, 2022 08:51
@cataggar cataggar requested review from briancr-ms and bmc-msft and removed request for briancr-ms March 25, 2022 08:52
@cataggar cataggar merged commit e714cfc into Azure:main Mar 25, 2022
@cataggar cataggar deleted the create_task_thiserror branch March 25, 2022 14:02
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.

3 participants