use std::io;
use std::path::Path;
use std::path::PathBuf;
use std::process::ExitCode;
use thiserror::Error;
pub type DaloResult<T> = Result<T, DaloError>;
#[derive(Debug, Error)]
pub enum DaloError {
#[error("{reason}")]
InvalidArgument {
reason: String,
},
#[error("check failed: {reason}")]
CheckFailed {
reason: String,
},
#[error("{reason}")]
StateError {
reason: String,
},
#[error("security audit blocked operation: {reason}")]
AuditBlocked {
reason: String,
},
#[error("command `{command}` is not implemented yet")]
NotImplemented {
command: String,
},
#[error("could not resolve the dalo store path: {reason}")]
StorePath {
reason: String,
},
#[error("invalid store path `{path}`: {reason}")]
InvalidStorePath {
path: PathBuf,
reason: String,
},
#[error(transparent)]
TomlSerialize(#[from] toml::ser::Error),
#[error(transparent)]
Json(#[from] serde_json::Error),
#[error(
"dalo store is not initialized at `{path}`; run `{}` first",
crate::store::dalo_command(.path.as_path(), "init")
)]
StoreNotInitialized {
path: PathBuf,
},
#[error("unknown target `{target}`{hint}")]
UnknownTarget {
target: String,
hint: String,
},
#[error("target `{target}` requires an explicit path")]
TargetPathRequired {
target: String,
},
#[error("source `{source_id}` already exists")]
SourceAlreadyExists {
source_id: String,
},
#[error("source checkout already exists at `{path}`; {reason}")]
SourceCheckoutExists {
path: PathBuf,
reason: String,
},
#[error("invalid source id `{id}`: {reason}")]
InvalidSourceId {
id: String,
reason: String,
},
#[error(
"Git URL uses an unsafe transport or contains userinfo; use a local path, an SSH URL, or a credential helper instead"
)]
UnsafeRemoteUrl,
#[error("unknown source `{source_id}`{hint}")]
UnknownSource {
source_id: String,
hint: String,
},
#[error(
"source `{source_id}` has local changes at `{path}`; inspect with `git -C {} status`, then resolve or commit them before syncing",
shell_quote_path(.path.as_path())
)]
DirtySource {
source_id: String,
path: PathBuf,
},
#[error("source `{source_id}` at `{path}` cannot fast-forward to its configured upstream")]
TrackingSourceNotFastForward {
source_id: String,
path: PathBuf,
},
#[error(
"catalog `{catalog_id}` upstream revision {upstream} is not a fast-forward from pinned revision {pinned}"
)]
CatalogNotFastForward {
catalog_id: String,
upstream: String,
pinned: String,
},
#[error(
"source `{source_id}` is the local source; its priority is fixed and cannot be changed"
)]
LocalSourcePriorityFixed {
source_id: String,
},
#[error("skill `{skill}` was not found{hint}")]
SkillNotFound {
skill: String,
hint: String,
},
#[error("instruction pack `{pack_id}` was not found; create `{path}` before enabling it")]
InstructionPackNotFound {
pack_id: String,
path: PathBuf,
},
#[error("instruction target `{path}` changed on disk; re-run the command")]
InstructionTargetChanged {
path: PathBuf,
},
#[error("local skill destination `{path}` already exists; dalo will not overwrite it")]
AdoptionDestinationExists {
path: PathBuf,
},
#[error("another dalo operation is running (lock `{path}`)")]
StoreLocked {
path: PathBuf,
},
#[error(
"unsupported schema version {version} in `{path}`; this dalo supports version {supported}; upgrade dalo"
)]
UnsupportedSchema {
path: PathBuf,
version: u32,
supported: u32,
},
#[error(
"cannot merge additive state field `{field}` for materialization directory `{path}` because previous target records contain conflicting values; use a newer dalo version or keep the targets on separate paths"
)]
StateMetadataConflict {
path: PathBuf,
field: String,
},
#[error("could not migrate legacy inventory for catalog `{source_id}`: {reason}")]
CatalogMigrationFailed {
source_id: String,
reason: String,
},
#[error("command `{program}` failed with status {status}: {stderr}")]
CommandFailed {
program: String,
args: String,
cwd: PathBuf,
status: String,
stderr: String,
},
#[error("agent reviewer `{requested}` is unavailable: {reason}")]
AgentUnavailable {
requested: String,
reason: String,
},
#[error("agent reviewer `{provider}` failed: {reason}")]
AgentReviewFailed {
provider: String,
reason: String,
},
#[error("could not parse `{path}`: {reason}")]
FileParse {
path: PathBuf,
reason: String,
},
#[error(
"could not parse state file `{path}`: {reason}; run `dalo init` to back it up and regenerate an empty state file"
)]
CorruptState {
path: PathBuf,
reason: String,
},
#[error(
"source `{source_id}` is not a catalog source; team sources sync all skills automatically (`dalo sync` refreshes them). To select individual skills, re-add it with `dalo source add-catalog`"
)]
NotACatalogSource {
source_id: String,
},
#[error(
"catalog skill reference `{reference}` is ambiguous; select by catalog-relative path; matches: {matches}"
)]
AmbiguousSkillReference {
reference: String,
matches: String,
},
#[error("skill selector `{selector}` is ambiguous; choose one of: {matches}")]
AmbiguousSkillSelector {
selector: String,
matches: String,
},
#[error("malformed instruction block for `{pack_id}`: {reason}")]
MalformedInstructionBlock {
pack_id: String,
reason: String,
},
#[error(transparent)]
Io(#[from] io::Error),
}
#[must_use]
pub(crate) fn shell_quote_path(path: &Path) -> String {
format!("'{}'", path.to_string_lossy().replace('\'', "'\"'\"'"))
}
#[must_use]
pub(crate) fn shell_quote_argument(value: &str) -> String {
if value.bytes().all(|byte| {
byte.is_ascii_alphanumeric()
|| matches!(
byte,
b'_' | b'@' | b'%' | b'+' | b'=' | b':' | b',' | b'.' | b'/' | b'-'
)
}) && !value.is_empty()
{
return value.to_owned();
}
format!("'{}'", value.replace('\'', "'\"'\"'"))
}
impl DaloError {
#[must_use]
pub fn unknown_target(target: impl Into<String>, known_targets: Vec<String>) -> Self {
let target = target.into();
Self::UnknownTarget {
hint: known_ids_hint("targets", &target, known_targets, "dalo target detect"),
target,
}
}
#[must_use]
pub fn unknown_source(source_id: impl Into<String>, known_sources: Vec<String>) -> Self {
let source_id = source_id.into();
Self::UnknownSource {
hint: known_ids_hint("sources", &source_id, known_sources, "dalo source list"),
source_id,
}
}
#[must_use]
pub fn skill_not_found(
skill: impl Into<String>,
known_skills: Vec<String>,
next_command: impl AsRef<str>,
) -> Self {
let skill = skill.into();
Self::skill_not_found_for_reference(skill.clone(), &skill, known_skills, next_command)
}
#[must_use]
pub fn skill_not_found_for_reference(
skill: impl Into<String>,
reference: &str,
known_skills: Vec<String>,
next_command: impl AsRef<str>,
) -> Self {
let skill = skill.into();
Self::SkillNotFound {
hint: known_ids_hint("skills", reference, known_skills, next_command.as_ref()),
skill,
}
}
#[must_use]
pub(crate) fn source_instruction_pack_not_found(
pack: impl Into<String>,
pack_id: &str,
known_packs: Vec<String>,
) -> Self {
Self::StateError {
reason: format!(
"instruction pack `{}` was not found{}; add the pack to the source repository and sync",
pack.into(),
known_ids_hint("instruction packs", pack_id, known_packs, "dalo status")
),
}
}
#[must_use]
pub fn exit_code(&self) -> DaloExitCode {
match self {
Self::InvalidArgument { .. }
| Self::CheckFailed { .. }
| Self::StateError { .. }
| Self::CatalogNotFastForward { .. }
| Self::AuditBlocked { .. }
| Self::NotImplemented { .. }
| Self::StoreNotInitialized { .. }
| Self::UnknownTarget { .. }
| Self::TargetPathRequired { .. }
| Self::SourceAlreadyExists { .. }
| Self::SourceCheckoutExists { .. }
| Self::InvalidSourceId { .. }
| Self::UnsafeRemoteUrl
| Self::TrackingSourceNotFastForward { .. }
| Self::NotACatalogSource { .. }
| Self::AmbiguousSkillReference { .. }
| Self::AmbiguousSkillSelector { .. }
| Self::UnknownSource { .. }
| Self::SkillNotFound { .. }
| Self::InstructionPackNotFound { .. }
| Self::AdoptionDestinationExists { .. }
| Self::UnsupportedSchema { .. }
| Self::FileParse { .. }
| Self::CorruptState { .. }
| Self::LocalSourcePriorityFixed { .. } => DaloExitCode::ExpectedFailure,
Self::DirtySource { .. }
| Self::StoreLocked { .. }
| Self::StateMetadataConflict { .. }
| Self::MalformedInstructionBlock { .. }
| Self::InstructionTargetChanged { .. } => DaloExitCode::UnsafeState,
Self::StorePath { .. }
| Self::InvalidStorePath { .. }
| Self::CommandFailed { .. }
| Self::CatalogMigrationFailed { .. }
| Self::AgentUnavailable { .. }
| Self::AgentReviewFailed { .. } => DaloExitCode::EnvironmentProblem,
Self::TomlSerialize(_) | Self::Json(_) => DaloExitCode::ExpectedFailure,
Self::Io(_) => DaloExitCode::EnvironmentProblem,
}
}
}
const MAX_KNOWN_IDS_IN_HINT: usize = 8;
const MAX_SUGGESTION_DISTANCE: usize = 2;
fn known_ids_hint(
label: &str,
unknown_id: &str,
mut ids: Vec<String>,
next_command: &str,
) -> String {
ids.sort();
ids.dedup();
let suggestion = unique_nearby_id(unknown_id, &ids)
.map(|id| format!("; did you mean `{id}`?"))
.unwrap_or_default();
let recovery = if ids.is_empty() {
format!("; run `{next_command}`")
} else if ids.len() <= MAX_KNOWN_IDS_IN_HINT {
format!("; known {label}: {}", ids.join(", "))
} else {
format!("; run `{next_command}`")
};
format!("{suggestion}{recovery}")
}
fn unique_nearby_id<'a>(unknown_id: &str, ids: &'a [String]) -> Option<&'a str> {
let mut candidates = ids
.iter()
.filter(|id| levenshtein_distance(unknown_id, id) <= MAX_SUGGESTION_DISTANCE);
match (candidates.next(), candidates.next()) {
(Some(candidate), None) => Some(candidate),
_ => None,
}
}
fn levenshtein_distance(left: &str, right: &str) -> usize {
let right = right.chars().collect::<Vec<_>>();
let mut previous = (0..=right.len()).collect::<Vec<_>>();
for (left_index, left_char) in left.chars().enumerate() {
let mut current = Vec::with_capacity(right.len() + 1);
current.push(left_index + 1);
for (right_index, right_char) in right.iter().enumerate() {
let insertion = current[right_index] + 1;
let deletion = previous[right_index + 1] + 1;
let substitution = previous[right_index] + usize::from(left_char != *right_char);
current.push(insertion.min(deletion).min(substitution));
}
previous = current;
}
previous[right.len()]
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DaloExitCode {
Success = 0,
ExpectedFailure = 1,
UnsafeState = 3,
EnvironmentProblem = 4,
}
impl From<DaloExitCode> for ExitCode {
fn from(code: DaloExitCode) -> Self {
Self::from(code as u8)
}
}
impl DaloExitCode {
#[must_use]
pub fn as_str(self) -> &'static str {
match self {
Self::Success => "success",
Self::ExpectedFailure => "expected_failure",
Self::UnsafeState => "unsafe_state",
Self::EnvironmentProblem => "environment_problem",
}
}
}
#[cfg(test)]
mod tests {
use super::*;
fn err<T>(result: DaloResult<T>) -> DaloError
where
T: std::fmt::Debug,
{
result.expect_err("operation should fail")
}
#[test]
fn not_implemented_should_use_expected_failure_exit_code() {
let error = DaloError::NotImplemented {
command: "sync".to_owned(),
};
assert_eq!(error.exit_code(), DaloExitCode::ExpectedFailure);
}
#[test]
fn not_implemented_should_render_command_name() {
let error = err::<()>(Err(DaloError::NotImplemented {
command: "sync".to_owned(),
}));
assert_eq!(error.to_string(), "command `sync` is not implemented yet");
}
#[test]
fn store_path_should_render_reason() {
let error = err::<()>(Err(DaloError::StorePath {
reason: "HOME is not set".to_owned(),
}));
assert_eq!(
error.to_string(),
"could not resolve the dalo store path: HOME is not set"
);
}
#[test]
fn invalid_store_path_should_render_path_and_reason() {
let error = err::<()>(Err(DaloError::InvalidStorePath {
path: PathBuf::from("/tmp/store"),
reason: "path is empty".to_owned(),
}));
assert_eq!(
error.to_string(),
"invalid store path `/tmp/store`: path is empty"
);
}
#[test]
fn store_not_initialized_should_render_path() {
let error = err::<()>(Err(DaloError::StoreNotInitialized {
path: PathBuf::from("/tmp/store with $(shell)/it's"),
}));
assert_eq!(
error.to_string(),
"dalo store is not initialized at `/tmp/store with $(shell)/it's`; run `dalo --store '/tmp/store with $(shell)/it'\"'\"'s' init` first"
);
}
#[test]
fn unknown_target_should_render_target_id() {
let error = err::<()>(Err(DaloError::UnknownTarget {
target: "codex".to_owned(),
hint: String::new(),
}));
assert_eq!(error.to_string(), "unknown target `codex`");
}
#[test]
fn known_id_hints_should_suggest_only_one_nearby_match() {
let target_hint = known_ids_hint(
"targets",
"cluade",
vec![
"claude".to_owned(),
"codex".to_owned(),
"generic".to_owned(),
"hermes".to_owned(),
"opencode".to_owned(),
"openclaw".to_owned(),
],
"dalo target detect",
);
assert!(target_hint.contains("did you mean `claude`?"));
assert!(target_hint.contains("known targets:"));
assert!(target_hint.contains("openclaw"));
let ambiguous_hint = known_ids_hint(
"sources",
"teem",
vec!["team".to_owned(), "term".to_owned()],
"dalo source list",
);
assert!(!ambiguous_hint.contains("did you mean"));
}
#[test]
fn target_path_required_should_render_target_id() {
let error = err::<()>(Err(DaloError::TargetPathRequired {
target: "generic".to_owned(),
}));
assert_eq!(
error.to_string(),
"target `generic` requires an explicit path"
);
}
#[test]
fn source_already_exists_should_render_source_id() {
let error = err::<()>(Err(DaloError::SourceAlreadyExists {
source_id: "company".to_owned(),
}));
assert_eq!(error.to_string(), "source `company` already exists");
}
#[test]
fn invalid_source_id_should_render_id_and_reason() {
let error = err::<()>(Err(DaloError::InvalidSourceId {
id: "../../evil".to_owned(),
reason: "contains `/`".to_owned(),
}));
assert_eq!(
error.to_string(),
"invalid source id `../../evil`: contains `/`"
);
}
#[test]
fn invalid_source_id_should_use_expected_failure_exit_code() {
let error = DaloError::InvalidSourceId {
id: "a/b".to_owned(),
reason: "contains `/`".to_owned(),
};
assert_eq!(error.exit_code(), DaloExitCode::ExpectedFailure);
}
#[test]
fn unknown_source_should_render_source_id() {
let error = err::<()>(Err(DaloError::UnknownSource {
source_id: "company".to_owned(),
hint: String::new(),
}));
assert_eq!(error.to_string(), "unknown source `company`");
}
#[test]
fn dirty_source_should_render_source_id() {
let error = err::<()>(Err(DaloError::DirtySource {
source_id: "company".to_owned(),
path: PathBuf::from("/tmp/store/sources/company/checkout"),
}));
assert_eq!(
error.to_string(),
"source `company` has local changes at `/tmp/store/sources/company/checkout`; inspect with `git -C '/tmp/store/sources/company/checkout' status`, then resolve or commit them before syncing"
);
}
#[test]
fn shell_quote_path_should_keep_metacharacters_in_one_literal_word() {
assert_eq!(
shell_quote_path(Path::new("/tmp/Jane's $(checkout); rm -rf nope")),
"'/tmp/Jane'\"'\"'s $(checkout); rm -rf nope'"
);
}
#[test]
fn shell_quote_argument_should_preserve_safe_ids_and_quote_shell_syntax() {
assert_eq!(shell_quote_argument("copy-editing"), "copy-editing");
assert_eq!(
shell_quote_argument("copy editing; $(touch nope) 'quoted'"),
"'copy editing; $(touch nope) '\"'\"'quoted'\"'\"''"
);
}
#[test]
fn skill_not_found_should_render_selector() {
let error = err::<()>(Err(DaloError::SkillNotFound {
skill: "review".to_owned(),
hint: String::new(),
}));
assert_eq!(error.to_string(), "skill `review` was not found");
}
#[test]
fn instruction_pack_not_found_should_render_expected_path() {
let error = err::<()>(Err(DaloError::InstructionPackNotFound {
pack_id: "house-style".to_owned(),
path: PathBuf::from("/tmp/store/local/instructions/house-style.md"),
}));
assert_eq!(
error.to_string(),
"instruction pack `house-style` was not found; create `/tmp/store/local/instructions/house-style.md` before enabling it"
);
}
#[test]
fn source_instruction_pack_not_found_should_render_state_error_guidance() {
let error = DaloError::source_instruction_pack_not_found(
"company:enginering-defaults",
"enginering-defaults",
vec!["engineering-defaults".to_owned()],
);
assert!(matches!(error, DaloError::StateError { .. }));
assert_eq!(
error.to_string(),
"instruction pack `company:enginering-defaults` was not found; did you mean `engineering-defaults`?; known instruction packs: engineering-defaults; add the pack to the source repository and sync"
);
}
#[test]
fn instruction_target_changed_should_render_unsafe_state() {
let error = DaloError::InstructionTargetChanged {
path: PathBuf::from("/tmp/AGENTS.md"),
};
assert_eq!(error.exit_code(), DaloExitCode::UnsafeState);
assert_eq!(
error.to_string(),
"instruction target `/tmp/AGENTS.md` changed on disk; re-run the command"
);
}
#[test]
fn adoption_destination_exists_should_render_path() {
let error = err::<()>(Err(DaloError::AdoptionDestinationExists {
path: PathBuf::from("/tmp/local/review"),
}));
assert_eq!(
error.to_string(),
"local skill destination `/tmp/local/review` already exists; dalo will not overwrite it"
);
}
#[test]
fn store_locked_should_render_lock_path() {
let error = err::<()>(Err(DaloError::StoreLocked {
path: PathBuf::from("/tmp/store/.lock"),
}));
assert_eq!(
error.to_string(),
"another dalo operation is running (lock `/tmp/store/.lock`)"
);
}
#[test]
fn unsupported_schema_should_render_versions_and_use_expected_failure() {
let error = DaloError::UnsupportedSchema {
path: PathBuf::from("/tmp/store/state.toml"),
version: 999,
supported: 1,
};
assert_eq!(error.exit_code(), DaloExitCode::ExpectedFailure);
assert_eq!(
error.to_string(),
"unsupported schema version 999 in `/tmp/store/state.toml`; this dalo supports version 1; upgrade dalo"
);
}
#[test]
fn command_failed_should_render_program_and_status() {
let error = err::<()>(Err(DaloError::CommandFailed {
program: "git".to_owned(),
args: "pull".to_owned(),
cwd: PathBuf::from("/tmp/checkout"),
status: "exit status: 1".to_owned(),
stderr: "boom".to_owned(),
}));
assert_eq!(
error.to_string(),
"command `git` failed with status exit status: 1: boom"
);
}
#[test]
fn command_failed_should_keep_the_public_fields_and_error_text() {
let error = DaloError::CommandFailed {
program: "git\u{1b}]0;program\u{7}".to_owned(),
args: "clone".to_owned(),
cwd: PathBuf::from("/tmp/checkout"),
status: "128".to_owned(),
stderr:
"Could not clone repository `team\u{7}`.\n\nGit said: fatal: \u{1b}[2Jbad\noutput"
.to_owned(),
};
assert_eq!(
error.to_string(),
"command `git\u{1b}]0;program\u{7}` failed with status 128: Could not clone repository `team\u{7}`.\n\nGit said: fatal: \u{1b}[2Jbad\noutput"
);
assert_eq!(
serde_json::to_value(error.to_string()).expect("error message should serialize"),
"command `git\u{1b}]0;program\u{7}` failed with status 128: Could not clone repository `team\u{7}`.\n\nGit said: fatal: \u{1b}[2Jbad\noutput"
);
}
#[test]
fn command_failed_should_preserve_empty_stderr() {
let error = DaloError::CommandFailed {
program: "git".to_owned(),
args: "clone".to_owned(),
cwd: PathBuf::from("/tmp/checkout"),
status: "128".to_owned(),
stderr: String::new(),
};
assert_eq!(error.to_string(), "command `git` failed with status 128: ");
}
#[test]
fn expected_failure_exit_codes_should_cover_actionable_variants() {
let cases = [
DaloError::InvalidArgument {
reason: "invalid value".to_owned(),
},
DaloError::NotImplemented {
command: "sync".to_owned(),
},
DaloError::StoreNotInitialized {
path: PathBuf::from("/tmp/store"),
},
DaloError::UnknownTarget {
target: "codex".to_owned(),
hint: String::new(),
},
DaloError::TargetPathRequired {
target: "generic".to_owned(),
},
DaloError::SourceAlreadyExists {
source_id: "company".to_owned(),
},
DaloError::SourceCheckoutExists {
path: PathBuf::from("/tmp/store/sources/company/checkout"),
reason: "move or remove it before retrying".to_owned(),
},
DaloError::TrackingSourceNotFastForward {
source_id: "company".to_owned(),
path: PathBuf::from("/tmp/store/sources/company/checkout"),
},
DaloError::UnknownSource {
source_id: "company".to_owned(),
hint: String::new(),
},
DaloError::SkillNotFound {
skill: "review".to_owned(),
hint: String::new(),
},
DaloError::InstructionPackNotFound {
pack_id: "house-style".to_owned(),
path: PathBuf::from("/tmp/store/local/instructions/house-style.md"),
},
DaloError::AdoptionDestinationExists {
path: PathBuf::from("/tmp/local/review"),
},
DaloError::UnsupportedSchema {
path: PathBuf::from("/tmp/store/lock.toml"),
version: 999,
supported: 1,
},
DaloError::StateError {
reason: "team manifest does not exist".to_owned(),
},
DaloError::CatalogNotFastForward {
catalog_id: "company.marketing".to_owned(),
upstream: "abc123".to_owned(),
pinned: "def456".to_owned(),
},
];
assert!(
cases
.iter()
.all(|error| error.exit_code() == DaloExitCode::ExpectedFailure)
);
}
#[test]
fn state_error_should_render_without_a_check_prefix() {
let error = err::<()>(Err(DaloError::StateError {
reason: "team manifest `/x/dalo.toml` does not exist".to_owned(),
}));
assert_eq!(
error.to_string(),
"team manifest `/x/dalo.toml` does not exist"
);
assert!(!error.to_string().contains("check failed"));
assert_eq!(error.exit_code(), DaloExitCode::ExpectedFailure);
}
#[test]
fn catalog_not_fast_forward_should_render_revisions() {
let error = err::<()>(Err(DaloError::CatalogNotFastForward {
catalog_id: "company.marketing".to_owned(),
upstream: "abc123".to_owned(),
pinned: "def456".to_owned(),
}));
assert_eq!(
error.to_string(),
"catalog `company.marketing` upstream revision abc123 is not a fast-forward from pinned revision def456"
);
assert_eq!(error.exit_code(), DaloExitCode::ExpectedFailure);
}
#[test]
fn unsafe_state_exit_codes_should_cover_blocking_variants() {
let cases = [
DaloError::DirtySource {
source_id: "company".to_owned(),
path: PathBuf::from("/tmp/store/sources/company/checkout"),
},
DaloError::StoreLocked {
path: PathBuf::from("/tmp/store/.lock"),
},
];
assert!(
cases
.iter()
.all(|error| error.exit_code() == DaloExitCode::UnsafeState)
);
}
#[test]
fn environment_problem_exit_codes_should_cover_dependency_variants() {
let cases = [
DaloError::StorePath {
reason: "HOME is not set".to_owned(),
},
DaloError::InvalidStorePath {
path: PathBuf::from("/tmp/store"),
reason: "path is empty".to_owned(),
},
DaloError::CommandFailed {
program: "git".to_owned(),
args: "pull".to_owned(),
cwd: PathBuf::from("/tmp/checkout"),
status: "exit status: 1".to_owned(),
stderr: "boom".to_owned(),
},
DaloError::Io(io::Error::other("disk full")),
];
assert!(
cases
.iter()
.all(|error| error.exit_code() == DaloExitCode::EnvironmentProblem)
);
}
#[test]
fn exit_code_should_convert_to_process_exit_code() {
let code: ExitCode = DaloExitCode::UnsafeState.into();
assert_eq!(code, ExitCode::from(3));
}
}