Skip to content

Commit

Permalink
fix: add fs.PathError handling
Browse files Browse the repository at this point in the history
  • Loading branch information
GalvinGao committed Jul 17, 2022
1 parent 2085a45 commit 4351e27
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/server/httpserver/error.go
Expand Up @@ -2,6 +2,7 @@ package httpserver

import (
"context"
"io/fs"
"strconv"

"github.com/davecgh/go-spew/spew"
Expand Down Expand Up @@ -69,6 +70,11 @@ func ErrorHandler(ctx *fiber.Ctx, err error) error {
return fiber.DefaultErrorHandler(ctx, e)
}

if _, ok := err.(*fs.PathError); ok {
// File not found
return HandleCustomError(ctx, pgerr.ErrInvalidReq)
}

// must be an unexpected runtime error then
log.Error().
Stack().
Expand Down

0 comments on commit 4351e27

Please sign in to comment.