mirror of
https://github.com/usememos/memos.git
synced 2024-11-10 08:52:22 +08:00
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:
parent
e4a09c407c
commit
2c819ace4e
2 changed files with 7 additions and 1 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -23,3 +23,6 @@ bin/air
|
|||
dev-dist
|
||||
|
||||
dist
|
||||
|
||||
# VSCode settings
|
||||
/.vscode
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue