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

blob: convert gocloud errors in Open() into appropriate fs errors #3443

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions blob/blob_fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@

import (
"context"
"fmt"
"io"
"io/fs"
"path/filepath"
"time"

"gocloud.dev/gcerrors"
"gocloud.dev/internal/gcerr"
)

Expand Down Expand Up @@ -203,6 +205,13 @@
// It's a file; open it and return a wrapper.
r, err := b.NewReader(ctx, path, readerOpts)
if err != nil {
code := gcerrors.Code(err)
switch code {
case gcerrors.NotFound:
err = fmt.Errorf("%w: %w", err, fs.ErrNotExist)
case gcerrors.PermissionDenied:
err = fmt.Errorf("%w: %w", err, fs.ErrPermission)

Check warning on line 213 in blob/blob_fs.go

View check run for this annotation

Codecov / codecov/patch

blob/blob_fs.go#L208-L213

Added lines #L208 - L213 were not covered by tests
}
return nil, &fs.PathError{Op: "open", Path: path, Err: err}
}
return &iofsOpenFile{r, filepath.Base(path)}, nil
Expand Down
Loading