gftp/result
Error types and result aliases for gftp operations.
All gftp functions return FtpResult(a) which is Result(a, FtpError).
import gftp
import gftp/result
case gftp.cwd(client, "/nonexistent") {
Ok(_) -> // success
Error(err) -> {
let msg = result.describe_error(err)
// "Unexpected response: [requested action not taken; file unavailable] ..."
}
}
Types
pub type FtpError {
ConnectionError(mug.ConnectError)
UnexpectedResponse(response.Response)
BadResponse
Tls(kafein.Error)
Socket(mug.Error)
}
Constructors
-
ConnectionError(mug.ConnectError)Connection error
-
UnexpectedResponse(response.Response)Unexpected response from remote. The command expected a certain response, but got another one. This means the ftp server refused to perform your request or there was an error while processing it. Contains the response data.
-
BadResponseThe response syntax is invalid
-
Tls(kafein.Error)An error occurred during a TLS handshake or while sending/receiving data over a TLS stream.
-
Socket(mug.Error)The address provided was invalid
Values
pub fn describe_error(err: FtpError) -> String
Convert an FtpError to a human-readable string.
let msg = result.describe_error(err)
// e.g. "Connection error: Connection refused"
// e.g. "Unexpected response: [user not logged in] Login required"