-
-
Notifications
You must be signed in to change notification settings - Fork 169
Implement core::error::Error for all error types #916
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
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 the PR!
uefi/src/data_types/strs.rs
Outdated
f, | ||
"{}", | ||
match self { | ||
Self::InvalidChar(_usize) => "invalid character", |
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.
For variants like this that contain extra info, I think we should go ahead and include that in the error message: write!(f, "invalid character at index {index}")
CHANGELOG.md
Outdated
@@ -15,6 +15,7 @@ | |||
- `FileSystem::copy` is now more efficient for large files. | |||
- `MpService::startup_all_aps` and `MpService::startup_this_ap` now accept an | |||
optional `event` parameter to allow non-blocking operation. | |||
- Added `core::error::Error` implementations to all error types |
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.
Nit: period at end of sentence.
uefi/src/proto/network/pxe.rs
Outdated
@@ -1278,6 +1287,15 @@ pub struct TftpError { | |||
pub error_string: [u8; 127], | |||
} | |||
|
|||
impl Display for TftpError { | |||
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { |
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.
tiny nit: can drop the core::
here since fmt
is already imported
uefi/src/data_types/strs.rs
Outdated
"{}", | ||
match self { | ||
Self::InvalidChar(_usize) => "invalid character", | ||
Self::InteriorNul(_usize) => "encountered null character", |
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.
For the interior null error, maybe something like "interior null character at index {index}"
, to clarify that it's specifically an interior null that is the problem (a trailing null is expected and required).
Thanks for the contribution, this is a good addition! |
a35e64d
to
4dc61a4
Compare
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.
Lgtm, thanks :)
Implemented
core::error::Error
andcore::fmt::Display
for all error types. Addresses #594I'm fairly new to Rust so there might be some coding conventions I'm not familiar with. I tried to match the style of existing
Display
implementations. Any and all feedback is appreciated.Checklist