errors.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. Copyright The containerd Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package v2
  14. import (
  15. "errors"
  16. "os"
  17. )
  18. var (
  19. ErrInvalidPid = errors.New("cgroups: pid must be greater than 0")
  20. ErrMountPointNotExist = errors.New("cgroups: cgroup mountpoint does not exist")
  21. ErrInvalidFormat = errors.New("cgroups: parsing file with invalid format failed")
  22. ErrFreezerNotSupported = errors.New("cgroups: freezer cgroup (v2) not supported on this system")
  23. ErrMemoryNotSupported = errors.New("cgroups: memory cgroup (v2) not supported on this system")
  24. ErrPidsNotSupported = errors.New("cgroups: pids cgroup (v2) not supported on this system")
  25. ErrCPUNotSupported = errors.New("cgroups: cpu cgroup (v2) not supported on this system")
  26. ErrCgroupDeleted = errors.New("cgroups: cgroup deleted")
  27. ErrNoCgroupMountDestination = errors.New("cgroups: cannot find cgroup mount destination")
  28. ErrInvalidGroupPath = errors.New("cgroups: invalid group path")
  29. )
  30. // ErrorHandler is a function that handles and acts on errors
  31. type ErrorHandler func(err error) error
  32. // IgnoreNotExist ignores any errors that are for not existing files
  33. func IgnoreNotExist(err error) error {
  34. if os.IsNotExist(err) {
  35. return nil
  36. }
  37. return err
  38. }
  39. func errPassthrough(err error) error {
  40. return err
  41. }