mirror of
https://github.com/gin-gonic/gin.git
synced 2025-12-16 15:09:11 +08:00
added more context to the error message when opening a file
This commit is contained in:
parent
a481ee2897
commit
9ea47029d3
6
fs.go
6
fs.go
@ -5,6 +5,7 @@
|
||||
package gin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
@ -29,11 +30,12 @@ func Dir(root string, listDirectory bool) http.FileSystem {
|
||||
return &onlyFilesFS{fs}
|
||||
}
|
||||
|
||||
// Open conforms to http.Filesystem.
|
||||
// Open opens a file excluding directories.
|
||||
// It conforms to http.Filesystem.
|
||||
func (fs onlyFilesFS) Open(name string) (http.File, error) {
|
||||
f, err := fs.fs.Open(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("failed to open file: %w", err)
|
||||
}
|
||||
return neuteredReaddirFile{f}, nil
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user