-
Notifications
You must be signed in to change notification settings - Fork 123
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
Conversation
|
Commit: 543e578
19 interesting tests: 18 KNOWN, 1 SKIP
Top 27 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.
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.
IMO this is a not a good thing. Adding common prefix is fine but replacing original error string entirely obscures underlying issue and hinders debugging.
(Unrelated to this PR, since this is happening on main as well).
|
Commit: 7aa738a
27 interesting tests: 18 KNOWN, 5 FAIL, 3 flaky, 1 SKIP
Top 50 slowest tests (at least 2 minutes):
|
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.