-
Notifications
You must be signed in to change notification settings - Fork 565
DeviceManagerError: Implement Error including all Variants #7061
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
Conversation
|
I was quite careful to ensure to not have any copy&paste errors. Fingers crossed! |
356ebc8 to
bbb89f2
Compare
rbradford
left a comment
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 for tackling this - this is a biggie!
pci/src/bus.rs
Outdated
| #[derive(Error, Debug)] | ||
| pub enum PciRootError { | ||
| /// Could not allocate device address space for the device. | ||
| #[error("Could not allocate device address space for the device")] |
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 the convention is that we put the embedded error after the message with a colon separating them - like "Could not allocate device address space for the device: {0}"
rockhopper:~/src/cloud-hypervisor (main)$ git grep "#\[error.*: {0}" | wc -l
586
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.
Please note that I'd like to change that treewide in/for #7066
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.
In which case we don't need to add that here.
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.
So for this commit, I follow the ": {0}" convention for the inner error for all enum variants that I touch anyway. This is likely going to be removed again in #7066, but this is another story
|
@phip1611 I'm confused - you adapted it to to the older style which means we can merge this sooner rather than holding it off? |
|
Sorry for the confusion.
Yes, adapted to the old style where each error's Display::fmt() also prints the sub error. We now have proper |
The DeviceManagerError type is among the types missing the Error trait so far. To streamline the code and to simplify usage on higher levels of this error type, this type now implements Display and Error. As not all variant values are Error yet, `#[source]` is not everywhere where it could be. This is done in the next commits. The high level goal is: Enable future work to improve the error output of cloud hypervisor. Signed-off-by: Philipp Schuster <[email protected]> On-behalf-of: SAP [email protected]
Signed-off-by: Philipp Schuster <[email protected]> On-behalf-of: SAP [email protected]
Signed-off-by: Philipp Schuster <[email protected]> On-behalf-of: SAP <[email protected]>
Signed-off-by: Philipp Schuster <[email protected]> On-behalf-of: SAP <[email protected]>
This format is also used elsewhere. Signed-off-by: Philipp Schuster <[email protected]> On-behalf-of: SAP <[email protected]>
96deca9
EDIT: This is a prerequisite for #7066. To have smaller PRs, this is a split-out.
The DeviceManagerError type is among the types missing the
Errortrait sofar. To streamline the code and to simplify usage on higher levels of this
error type, this type now implements Display and Error.
As not all variant values are Error yet,
#[source]is not everywhere whereit could be. This is done in the next commits.
The high level goal is: Enable future work to improve the error output of
cloud hypervisor.