Skip to content

fs: add new error type #792

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 3 commits into from
May 9, 2023
Merged

fs: add new error type #792

merged 3 commits into from
May 9, 2023

Conversation

phip1611
Copy link
Member

@phip1611 phip1611 commented May 6, 2023

In #472 I added an initial version of a file-system error type. I did not really like it. Therefore, this MR adds a new type which adds much more context to errors. I think, the new abstraction is helpful - yet kind of feature-creep 😁

What do you think?

Hints for Review

Changelog update is not needed I think, as none of the fs-related code is published yet.

Checklist

  • Sensible git history (for example, squash "typo" or "fix" commits). See the Rewriting History guide for help.
  • Update the changelog (if necessary)

@phip1611 phip1611 force-pushed the fs-err branch 4 times, most recently from e5203be to d6c05e6 Compare May 6, 2023 19:08
@phip1611 phip1611 marked this pull request as ready for review May 6, 2023 19:10
@phip1611
Copy link
Member Author

phip1611 commented May 6, 2023

@nicholasbishop this is now ready for review - what do you think? Is this helpful or overengineered?

Copy link
Member

@nicholasbishop nicholasbishop left a comment

Choose a reason for hiding this comment

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

Splitting up the error type looks good to me. Left a couple minor suggestions


/// Logical errors when working with files.
#[derive(Debug, Clone, Display, PartialEq, Eq)]
pub enum LogicError {
Copy link
Member

Choose a reason for hiding this comment

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

I think the LogicError variants should be merged into the IoError variants to simplify a bit (and that matches how std::io::ErrorKind works)

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 didn't know about std::io::ErrorKind, interesting!

/// UEFI-error with context when working with the underlying UEFI file protocol.
#[derive(Debug, Clone, Display, PartialEq, Eq)]
#[display(fmt = "FileSystemIOError({},{})", context, path)]
pub struct FileSystemIOError {
Copy link
Member

Choose a reason for hiding this comment

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

Naming nit: since this is already in the fs module, I think we can drop the FileSystem prefix from this and FileSystemIOErrorContext.

Also, per https://rust-lang.github.io/api-guidelines/naming.html, acronyms a treated as a word for capitalization, so IoError instead of IOError.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! I've updated the PR

@phip1611 phip1611 requested a review from nicholasbishop May 7, 2023 21:12
@nicholasbishop
Copy link
Member

Just making sure you saw -- CI failed. (Also there's an a commit that was probably meant to be squashed.)

@nicholasbishop nicholasbishop merged commit 023b08d into rust-osdev:main May 9, 2023
@phip1611 phip1611 deleted the fs-err branch May 25, 2023 09:41
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.

2 participants