error.go 525 B

123456789101112131415161718192021222324252627
  1. // Copyright 2020 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package osutil
  5. import (
  6. "os"
  7. "gogs.io/gogs/internal/errutil"
  8. )
  9. var _ errutil.NotFound = (*Error)(nil)
  10. // Error is a wrapper of an OS error, which handles not found.
  11. type Error struct {
  12. error
  13. }
  14. func (e Error) NotFound() bool {
  15. return e.error == os.ErrNotExist
  16. }
  17. // NewError wraps given error.
  18. func NewError(err error) error {
  19. return Error{error: err}
  20. }