-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support handlers returning explicit error codes
Add errors for all the SSH_FXP_STATUS codes to give the developer implementing request server handlers greater control over the returned codes. Most helpful in cases where nothing currently would work (eg. unsupported). Fixes pkg#223
- Loading branch information
Showing
3 changed files
with
80 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package sftp | ||
|
||
// 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. | ||
|
||
type fxerr uint32 | ||
|
||
const ( | ||
ErrSshFxOk = fxerr(ssh_FX_OK) | ||
ErrSshFxEof = fxerr(ssh_FX_EOF) | ||
ErrSshFxNoSuchFile = fxerr(ssh_FX_NO_SUCH_FILE) | ||
ErrSshFxPermissionDenied = fxerr(ssh_FX_PERMISSION_DENIED) | ||
ErrSshFxFailure = fxerr(ssh_FX_FAILURE) | ||
ErrSshFxBadMessage = fxerr(ssh_FX_BAD_MESSAGE) | ||
ErrSshFxNoConnection = fxerr(ssh_FX_NO_CONNECTION) | ||
ErrSshFxConnectionLost = fxerr(ssh_FX_CONNECTION_LOST) | ||
ErrSshFxOpUnsupported = fxerr(ssh_FX_OP_UNSUPPORTED) | ||
) | ||
|
||
func (e fxerr) Error() string { | ||
switch e { | ||
case ErrSshFxOk: | ||
return "OK" | ||
case ErrSshFxEof: | ||
return "EOF" | ||
case ErrSshFxNoSuchFile: | ||
return "No Such File" | ||
case ErrSshFxPermissionDenied: | ||
return "Permission Denied" | ||
case ErrSshFxBadMessage: | ||
return "Bad Message" | ||
case ErrSshFxNoConnection: | ||
return "No Connection" | ||
case ErrSshFxConnectionLost: | ||
return "Connection Lost" | ||
case ErrSshFxOpUnsupported: | ||
return "Operation Unsupported" | ||
default: | ||
return "Failure" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters