-
Notifications
You must be signed in to change notification settings - Fork 121
Unexport errors returned by the filer package #4156
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
base: main
Are you sure you want to change the base?
Conversation
|
Commit: fb49611
30 interesting tests: 14 KNOWN, 7 flaky, 6 RECOVERED, 2 FAIL, 1 SKIP
Top 50 slowest tests (at least 2 minutes):
|
|
|
||
| _, _, err = testcli.RequireErrorRun(t, ctx, "fs", "cat", path.Join(tmpDir, "dir1")) | ||
| assert.ErrorAs(t, err, &filer.NotAFile{}) | ||
| assert.ErrorIs(t, err, fs.ErrInvalid) |
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.
unrelated to this PR, but is fs.ErrInvalid a correct error to use? The docs say "invalid argument", implies bad arguments passed to the function, not an issue with remote object being a wrong type.
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.
Good point. The fs package doesn't have a better alternative. But if we need one, we could add a few constants to libs/filer for more specific checks.
| switch { | ||
| case errors.Is(err, fs.ErrNotExist): | ||
| return NoSuchDirectoryError{path: absPath} | ||
| return noSuchDirectoryError{path: absPath} |
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.
why replace fs.ErrNotExists with noSuchDirectoryError which pretends to be fs.ErrNotExist ?
People checking Is() will not see the difference.
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.
It normalizes the string Error() to be the same.
Why
Some call sites depended on the underlying type of the error. All callers can rely on error equivalence with the
fs.Err*errors instead. The next step is to include the underlying errors in case callers need access to additional error details. This can use the error wrapping/unwrapping pattern.Tests
Unit tests pass.