#[non_exhaustive]pub enum CliError {
Show 20 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),
ReadBackMismatch(String),
ConsentRefused(String),
CleanupPending(String),
AclNotEvaluated(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, a probe that did not read back, an answer naming another member or state than the one acted on, or an existing profile card that does not name its owner.
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)
A bounded wait ran out: join waited for the node to provision the
pod (rerunning join continues from where it stopped), or
member suspend --wait waited for the suspension to be enforced.
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.
ReadBackMismatch(String)
app install: a container’s ACL did not read back as it was
written, so consent was not sent. The message names the container.
ConsentRefused(String)
app install: consent was refused, by the node or because the
installation stopped being pending_consent before a write. The
message says which, and lists anything written that could not be
removed.
CleanupPending(String)
app withdraw or app cleanup: the withdrawn grant’s ACL cleanup
is still pending for at least one container.
AclNotEvaluated(String)
An ACL the client would have to rewrite holds a statement it does not evaluate, so it wrote nothing to that ACL. The message names the ACL and the statement.
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);Sourcepub fn code(&self) -> &str
pub fn code(&self) -> &str
Returns a short machine-readable code: the server’s error.code, or
one of usage, local, unreachable, protocol, refused,
invalid, not_confirmed, timed_out, export_incomplete,
read_back_mismatch, consent_refused, cleanup_pending and
acl_not_evaluated for failures found by the client.
Sourcepub fn hint(&self) -> Option<&'static str>
pub fn hint(&self) -> Option<&'static str>
Returns advice for a failure whose code alone does not say what to do
next, or None: a server error a person can meet, or one of the
client’s own grant and cleanup failures. The code, message and exit
code are not changed; the hint is printed after them.
§Examples
use stratum_node_cli::CliError;
let err = CliError::Server {
status: 409,
code: "archive_required".into(),
message: "no archive for this suspension".into(),
details: Vec::new(),
};
assert!(err.hint().is_some_and(|hint| hint.contains("--no-archive")));
assert_eq!(CliError::NotConfirmed.hint(), None);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()