pub struct GitwayError { /* private fields */ }Expand description
The single error type returned by all gitway-lib operations.
Provides is_* predicate methods so callers can branch on error categories
without depending on internal representation. A Backtrace is captured
automatically; it is rendered via std::fmt::Display when
RUST_BACKTRACE=1 is set.
§Predicates
| Method | Condition |
|---|---|
is_io | Underlying I/O failure |
is_host_key_mismatch | Server key does not match pinned fingerprints |
is_authentication_failed | Server rejected our key |
is_no_key_found | No identity key available |
is_key_encrypted | Key file needs a passphrase |
Implementations§
Source§impl GitwayError
impl GitwayError
pub fn host_key_mismatch(fingerprint: impl Into<String>) -> Self
pub fn authentication_failed() -> Self
pub fn no_key_found() -> Self
pub fn invalid_config(message: impl Into<String>) -> Self
Sourcepub fn is_host_key_mismatch(&self) -> bool
pub fn is_host_key_mismatch(&self) -> bool
Returns true if the server’s host key did not match any pinned fingerprint.
Sourcepub fn is_authentication_failed(&self) -> bool
pub fn is_authentication_failed(&self) -> bool
Returns true if the server rejected our public-key authentication attempt.
Sourcepub fn is_no_key_found(&self) -> bool
pub fn is_no_key_found(&self) -> bool
Returns true if no usable identity key was found.
Sourcepub fn is_key_encrypted(&self) -> bool
pub fn is_key_encrypted(&self) -> bool
Returns true if a key file was found but requires a passphrase to decrypt.
Sourcepub fn fingerprint(&self) -> Option<&str>
pub fn fingerprint(&self) -> Option<&str>
Returns the path at which an encrypted key was found, if applicable.
Sourcepub fn error_code(&self) -> &'static str
pub fn error_code(&self) -> &'static str
Returns an upper-snake-case error code for structured JSON output (SFRS Rule 5).
| Code | Exit code | Condition |
|---|---|---|
GENERAL_ERROR | 1 | I/O, SSH protocol, or key-parsing failure |
USAGE_ERROR | 2 | Invalid configuration or bad arguments |
NOT_FOUND | 3 | No identity key found |
PERMISSION_DENIED | 4 | Host key mismatch or authentication failure |
Sourcepub fn exit_code(&self) -> u32
pub fn exit_code(&self) -> u32
Returns the numeric process exit code for this error (SFRS Rule 2).
| Code | Meaning |
|---|---|
| 1 | General / unexpected error |
| 2 | Usage error (bad arguments, invalid configuration) |
| 3 | Not found (no identity key, unknown host) |
| 4 | Permission denied (authentication failure, host key mismatch) |
Trait Implementations§
Source§impl Debug for GitwayError
impl Debug for GitwayError
Source§impl Display for GitwayError
impl Display for GitwayError
Source§impl Error for GitwayError
impl Error for GitwayError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()