Replace error handling package with emperror; add better reporting for errors escaping server root
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package filesystem
|
||||
|
||||
import (
|
||||
"emperror.dev/errors"
|
||||
"encoding/json"
|
||||
"github.com/gabriel-vasile/mimetype"
|
||||
"os"
|
||||
@@ -50,14 +51,14 @@ func (fs *Filesystem) Stat(p string) (*Stat, error) {
|
||||
func (fs *Filesystem) unsafeStat(p string) (*Stat, error) {
|
||||
s, err := os.Stat(p)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errors.WithStackIf(err)
|
||||
}
|
||||
|
||||
var m *mimetype.MIME
|
||||
if !s.IsDir() {
|
||||
m, err = mimetype.DetectFile(p)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errors.WithStackIf(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user