Skip to content

Commit ee0472d

Browse files
committed
filesystem: use fserrors types for invalid ops
1 parent 2008ad7 commit ee0472d

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

internal/filesystem/filesystem.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"os"
1010
"time"
1111

12+
fserrors "github.com/djdv/go-filesystem-utils/internal/filesystem/errors"
1213
"github.com/djdv/go-filesystem-utils/internal/generic"
1314
)
1415

@@ -271,22 +272,18 @@ func Seek(file fs.File, offset int64, whence int) (int64, error) {
271272
}
272273

273274
func unsupportedOpErr(op, name string) error {
274-
return fmt.Errorf(
275-
op+` "%s": %w`,
276-
name, errors.ErrUnsupported,
277-
)
275+
return fserrors.New(op, name, errors.ErrUnsupported, fserrors.InvalidOperation)
278276
}
279277

280278
func unsupportedOpErr2(op, name1, name2 string) error {
281-
return fmt.Errorf(
282-
op+` "%s" -> "%s": %w`,
283-
name1, name2, errors.ErrUnsupported,
279+
name := fmt.Sprintf(
280+
`"%s" -> "%s"`,
281+
name1, name2,
284282
)
283+
return fserrors.New(op, name, errors.ErrUnsupported, fserrors.InvalidOperation)
285284
}
286285

287286
func unsupportedOpErrAnonymous(op string, subject any) error {
288-
return fmt.Errorf(
289-
op+` %T: %w`,
290-
subject, errors.ErrUnsupported,
291-
)
287+
name := fmt.Sprintf("%T", subject)
288+
return unsupportedOpErr(op, name)
292289
}

0 commit comments

Comments
 (0)