errutil.go 417 B

12345678910111213141516
  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 errutil
  5. // NotFound represents a not found error.
  6. type NotFound interface {
  7. NotFound() bool
  8. }
  9. // IsNotFound returns true if the error is a not found error.
  10. func IsNotFound(err error) bool {
  11. e, ok := err.(NotFound)
  12. return ok && e.NotFound()
  13. }