improve error wrapping

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2024-05-14 19:10:36 +02:00
parent eb0c6549c4
commit 665a980d62
6 changed files with 48 additions and 46 deletions

View File

@@ -223,16 +223,11 @@ func (t *BaseTransfer) SetCancelFn(cancelFn func()) {
// converts it into a more understandable form for the client if it is a
// well-known type of error
func (t *BaseTransfer) ConvertError(err error) error {
if t.Fs.IsNotExist(err) {
return t.Connection.GetNotExistError()
} else if t.Fs.IsPermission(err) {
return t.Connection.GetPermissionDeniedError()
}
var pathError *fs.PathError
if errors.As(err, &pathError) {
return fmt.Errorf("%s %s: %s", pathError.Op, t.GetVirtualPath(), pathError.Err.Error())
}
return err
return t.Connection.GetFsError(t.Fs, err)
}
// CheckRead returns an error if read if not allowed