Skip to content

Commit

Permalink
feat: return not found error instead internal error for local file no…
Browse files Browse the repository at this point in the history
…t 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
  • Loading branch information
RyoJerryYu authored Jun 10, 2024
1 parent e4a09c4 commit 2c819ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ bin/air

dev-dist

dist
dist

# VSCode settings
/.vscode
3 changes: 3 additions & 0 deletions server/router/api/v1/resource_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 2c819ac

Please sign in to comment.