feat: return not found error instead internal error for local file not exist (#3543)

* chore: add `/.vscode` to `.gitignore`

* feat: return not found instead of internal for resource

* feat: check file not exist only if error not nil
This commit is contained in:
Ryo 2024-06-10 14:11:28 +08:00 committed by GitHub
parent e4a09c407c
commit 2c819ace4e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

3
.gitignore vendored
View file

@ -23,3 +23,6 @@ bin/air
dev-dist
dist
# VSCode settings
/.vscode

View file

@ -198,6 +198,9 @@ func (s *APIV1Service) GetResourceBinary(ctx context.Context, request *v1pb.GetR
file, err := os.Open(resourcePath)
if err != nil {
if os.IsNotExist(err) {
return nil, status.Errorf(codes.NotFound, "file not found for resource: %s", request.Name)
}
return nil, status.Errorf(codes.Internal, "failed to open the file: %v", err)
}
defer file.Close()