#[non_exhaustive]pub enum CliError {
Show 16 variants
Usage(String),
Url(ParseUrlError),
MissingKeyFile,
KeyFile {
path: PathBuf,
source: KeyFileError,
},
TokenFile {
path: PathBuf,
source: TokenFileError,
},
File {
path: PathBuf,
source: PrivateFileError,
},
FileContents {
path: PathBuf,
message: String,
},
Unreachable {
url: String,
message: String,
},
Protocol(String),
Server {
status: u16,
code: String,
message: String,
details: Vec<String>,
},
Refused(String),
InvalidPreview {
details: Vec<String>,
},
NotConfirmed,
TimedOut(String),
ExportIncomplete(String),
Local(String),
}Expand description
Why a stratum command failed.
Each variant maps to a stable process exit code through
exit_code and to a short machine-readable code
through code. A server error displays as
code: message, exactly as the node sent it (with control characters
escaped). No variant ever carries the operator’s secret key or the
bootstrap token.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Usage(String)
The command line asks for something impossible, such as an unknown configuration path or a value of the wrong type.
Url(ParseUrlError)
The --url value was refused.
MissingKeyFile
A command needs the operator key and no --key-file was given.
KeyFile
The operator key file could not be created or loaded.
TokenFile
The bootstrap token file could not be read.
File
A file other than the key or token file (resume file, claim body file) could not be created, read or removed.
FileContents
A file was readable but its contents are not what the command needs.
Unreachable
The node could not be reached.
Protocol(String)
The node answered with something the API contract does not allow.
Server
The node refused the request with an error from the API contract.
Fields
Refused(String)
A local check refused what the node sent: a claim body naming another claimant or node, an expired claim, a manifest with a bad signature or another author, an admission notice for another node or with another hash, or a probe that did not read back.
InvalidPreview
A preview reported validation errors, so nothing was sent to apply.
NotConfirmed
Changes were previewed but not confirmed, so nothing was applied. Also
returned by every other command that asks first (join, pod rm,
member repair, member cancel): nothing was sent.
TimedOut(String)
join waited for the node to provision the pod and it did not
finish in time; rerunning join continues from where it stopped.
ExportIncomplete(String)
export wrote its archive and manifest, but entries changed,
vanished or were skipped during the walk; the manifest lists them.
Local(String)
Writing output, reading the clock or the random source, or signing failed.
Implementations§
Source§impl CliError
impl CliError
Sourcepub fn exit_code(&self) -> u8
pub fn exit_code(&self) -> u8
Returns the process exit code; see exit.
§Examples
use stratum_node_cli::{exit, CliError};
let err = CliError::Server {
status: 409,
code: "conflict".into(),
message: "stale base revision".into(),
details: Vec::new(),
};
assert_eq!(err.to_string(), "conflict: stale base revision");
assert_eq!(err.exit_code(), exit::CONFLICT);Trait Implementations§
Source§impl Error for CliError
impl Error for CliError
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()