classify.go 299 B

12345678910111213141516171819202122
  1. package backend
  2. import (
  3. "errors"
  4. "os"
  5. )
  6. func ClassifyOpen(err error) string {
  7. if err == nil {
  8. return ""
  9. }
  10. if os.IsNotExist(err) {
  11. return "not_found"
  12. }
  13. if os.IsPermission(err) {
  14. return "permission"
  15. }
  16. if errors.Is(err, ErrNotConnected) {
  17. return "disconnected"
  18. }
  19. return "other"
  20. }