rclone/vendor/github.com/pkg/sftp/request-errors.go

55 lines
1.7 KiB
Go
Raw Normal View History

2018-03-19 16:51:38 +01:00
package sftp
2020-02-25 15:20:57 +01:00
type fxerr uint32
2018-03-19 16:51:38 +01:00
// Error types that match the SFTP's SSH_FXP_STATUS codes. Gives you more
// direct control of the errors being sent vs. letting the library work them
// out from the standard os/io errors.
2020-02-25 15:20:57 +01:00
const (
ErrSSHFxOk = fxerr(sshFxOk)
ErrSSHFxEOF = fxerr(sshFxEOF)
ErrSSHFxNoSuchFile = fxerr(sshFxNoSuchFile)
ErrSSHFxPermissionDenied = fxerr(sshFxPermissionDenied)
ErrSSHFxFailure = fxerr(sshFxFailure)
ErrSSHFxBadMessage = fxerr(sshFxBadMessage)
ErrSSHFxNoConnection = fxerr(sshFxNoConnection)
ErrSSHFxConnectionLost = fxerr(sshFxConnectionLost)
ErrSSHFxOpUnsupported = fxerr(sshFxOPUnsupported)
)
2018-03-19 16:51:38 +01:00
2020-02-25 15:20:57 +01:00
// Deprecated error types, these are aliases for the new ones, please use the new ones directly
2018-03-19 16:51:38 +01:00
const (
2020-02-25 15:20:57 +01:00
ErrSshFxOk = ErrSSHFxOk
ErrSshFxEof = ErrSSHFxEOF
ErrSshFxNoSuchFile = ErrSSHFxNoSuchFile
ErrSshFxPermissionDenied = ErrSSHFxPermissionDenied
ErrSshFxFailure = ErrSSHFxFailure
ErrSshFxBadMessage = ErrSSHFxBadMessage
ErrSshFxNoConnection = ErrSSHFxNoConnection
ErrSshFxConnectionLost = ErrSSHFxConnectionLost
ErrSshFxOpUnsupported = ErrSSHFxOpUnsupported
2018-03-19 16:51:38 +01:00
)
func (e fxerr) Error() string {
switch e {
2020-02-25 15:20:57 +01:00
case ErrSSHFxOk:
2018-03-19 16:51:38 +01:00
return "OK"
2020-02-25 15:20:57 +01:00
case ErrSSHFxEOF:
2018-03-19 16:51:38 +01:00
return "EOF"
2020-02-25 15:20:57 +01:00
case ErrSSHFxNoSuchFile:
2018-03-19 16:51:38 +01:00
return "No Such File"
2020-02-25 15:20:57 +01:00
case ErrSSHFxPermissionDenied:
2018-03-19 16:51:38 +01:00
return "Permission Denied"
2020-02-25 15:20:57 +01:00
case ErrSSHFxBadMessage:
2018-03-19 16:51:38 +01:00
return "Bad Message"
2020-02-25 15:20:57 +01:00
case ErrSSHFxNoConnection:
2018-03-19 16:51:38 +01:00
return "No Connection"
2020-02-25 15:20:57 +01:00
case ErrSSHFxConnectionLost:
2018-03-19 16:51:38 +01:00
return "Connection Lost"
2020-02-25 15:20:57 +01:00
case ErrSSHFxOpUnsupported:
2018-03-19 16:51:38 +01:00
return "Operation Unsupported"
default:
return "Failure"
}
}