MCPcopy
hub / github.com/labstack/echo / isIgnorableOpenFileError

Function isIgnorableOpenFileError

middleware/static_other.go:13–30  ·  view source on GitHub ↗

We ignore these errors as there could be handler that matches request path.

(err error)

Source from the content-addressed store, hash-verified

11
12// We ignore these errors as there could be handler that matches request path.
13func isIgnorableOpenFileError(err error) bool {
14 if os.IsNotExist(err) {
15 return true
16 }
17 // As of Go 1.20 Windows path checks are more strict on the provided path and considers [UNC](https://en.wikipedia.org/wiki/Path_(computing)#UNC)
18 // paths with missing host etc parts as invalid. Previously it would result you `fs.ErrNotExist`.
19 // Also `fs.Open` on all OSes does not accept ``, `.`, `..` at all.
20 //
21 // so we need to treat those errors the same as `fs.ErrNotExists` so we can continue handling
22 // errors in the middleware/handler chain. Otherwise we might end up with status 500 instead of finding a route
23 // or return 404 not found.
24 var pErr *fs.PathError
25 if errors.As(err, &pErr) {
26 err = pErr.Err
27 return err.Error() == "invalid argument"
28 }
29 return false
30}

Callers 1

ToMiddlewareMethod · 0.85

Calls 1

ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…