request-errors.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package sftp
  2. type fxerr uint32
  3. // Error types that match the SFTP's SSH_FXP_STATUS codes. Gives you more
  4. // direct control of the errors being sent vs. letting the library work them
  5. // out from the standard os/io errors.
  6. const (
  7. ErrSSHFxOk = fxerr(sshFxOk)
  8. ErrSSHFxEOF = fxerr(sshFxEOF)
  9. ErrSSHFxNoSuchFile = fxerr(sshFxNoSuchFile)
  10. ErrSSHFxPermissionDenied = fxerr(sshFxPermissionDenied)
  11. ErrSSHFxFailure = fxerr(sshFxFailure)
  12. ErrSSHFxBadMessage = fxerr(sshFxBadMessage)
  13. ErrSSHFxNoConnection = fxerr(sshFxNoConnection)
  14. ErrSSHFxConnectionLost = fxerr(sshFxConnectionLost)
  15. ErrSSHFxOpUnsupported = fxerr(sshFxOPUnsupported)
  16. )
  17. // Deprecated error types, these are aliases for the new ones, please use the new ones directly
  18. const (
  19. ErrSshFxOk = ErrSSHFxOk
  20. ErrSshFxEof = ErrSSHFxEOF
  21. ErrSshFxNoSuchFile = ErrSSHFxNoSuchFile
  22. ErrSshFxPermissionDenied = ErrSSHFxPermissionDenied
  23. ErrSshFxFailure = ErrSSHFxFailure
  24. ErrSshFxBadMessage = ErrSSHFxBadMessage
  25. ErrSshFxNoConnection = ErrSSHFxNoConnection
  26. ErrSshFxConnectionLost = ErrSSHFxConnectionLost
  27. ErrSshFxOpUnsupported = ErrSSHFxOpUnsupported
  28. )
  29. func (e fxerr) Error() string {
  30. switch e {
  31. case ErrSSHFxOk:
  32. return "OK"
  33. case ErrSSHFxEOF:
  34. return "EOF"
  35. case ErrSSHFxNoSuchFile:
  36. return "no such file"
  37. case ErrSSHFxPermissionDenied:
  38. return "permission denied"
  39. case ErrSSHFxBadMessage:
  40. return "bad message"
  41. case ErrSSHFxNoConnection:
  42. return "no connection"
  43. case ErrSSHFxConnectionLost:
  44. return "connection lost"
  45. case ErrSSHFxOpUnsupported:
  46. return "operation unsupported"
  47. default:
  48. return "failure"
  49. }
  50. }