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

feat: show IO errors for files in the UI #1311

Closed
wants to merge 1 commit into from

Conversation

Ape
Copy link
Contributor

@Ape Ape commented Jul 19, 2024

Resolves #1137.

@Ape
Copy link
Contributor Author

Ape commented Jul 19, 2024

This actually accidentally partially fixes #1273, too. Turns out there was tostring missing in yazi-plugin/preset/components/current.lua.

The loading message still doesn't work in the folder preview view (yazi-plugin/preset/plugins/folder.lua), but that's outside the scope of this PR.

yazi-core/src/folder/files.rs Show resolved Hide resolved
pub enum FolderStage {
#[default]
Loading,
Loaded,
Failed(std::io::ErrorKind),
Failed(std::io::ErrorKind, String),
Copy link
Owner

Choose a reason for hiding this comment

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

Why don't we generate error messages through std::io::ErrorKind instead of saving them as strings?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There doesn't seem to be any way to do that.

Copy link
Owner

Choose a reason for hiding this comment

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

How about using the Display trait to do this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That doesn't give the pretty human readable messages, just the name of the kind.

Copy link
Owner

Choose a reason for hiding this comment

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

The error messages for the two cases NotFound and PermissionDenied are "entity not found" and "permission denied", which I think are quite readable. What does the current implementation look like?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The error strings in the current commit are the classic C / POSIX error messages with the os error code, e.g. "No such file or directory (os error 2)" or "Permission denied (os error 13)". I wanted to use these since they seem familiar and are easy to search details for especially when you encounter a rarer type of error that you might not understand.

However, I guess the ErrorKind strings are actually good enough and it makes the implementation simpler.

Copy link
Owner

Choose a reason for hiding this comment

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

However, I guess the ErrorKind strings are actually good enough and it makes the implementation simpler.

Nice, please change it! Let's implement it in the simplest way for now, if someone reports that it's not clear enough, we can create our own messages by ErrorKind.

yazi-plugin/preset/components/current.lua Show resolved Hide resolved
@sxyazi
Copy link
Owner

sxyazi commented Aug 9, 2024

I'm going to close this because it still needs some work and hasn't seen any activity recently. @Ape thanks for the effort!

@sxyazi sxyazi closed this Aug 9, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Give some hint/message when the content of a directory cannot be shown due to lack of permission
2 participants