We ignore these errors as there could be handler that matches request path.
(err error)
| 11 | |
| 12 | // We ignore these errors as there could be handler that matches request path. |
| 13 | func 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 | } |
no test coverage detected
searching dependent graphs…