fix(error): Remap ConfigNotFound to exit 20 and add NotFound/Ambiguous codes

ConfigNotFound previously used exit code 2 which collides with clap's
usage error code. Remap it to exit 20 to avoid ambiguity. Also add
dedicated NotFound (exit 17) and Ambiguous (exit 18) error codes with
proper ErrorCode variants and Display implementations, replacing the
previous incorrect mapping of these errors to GitLabNotFound.

Co-Authored-By: Claude (us.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
This commit is contained in:
Taylor Eernisse
2026-01-30 16:54:02 -05:00
parent 5508d8464a
commit 730ddef339

View File

@@ -24,6 +24,8 @@ pub enum ErrorCode {
OllamaUnavailable,
OllamaModelNotFound,
EmbeddingFailed,
NotFound,
Ambiguous,
}
impl std::fmt::Display for ErrorCode {
@@ -45,6 +47,8 @@ impl std::fmt::Display for ErrorCode {
Self::OllamaUnavailable => "OLLAMA_UNAVAILABLE",
Self::OllamaModelNotFound => "OLLAMA_MODEL_NOT_FOUND",
Self::EmbeddingFailed => "EMBEDDING_FAILED",
Self::NotFound => "NOT_FOUND",
Self::Ambiguous => "AMBIGUOUS",
};
write!(f, "{code}")
}
@@ -55,7 +59,7 @@ impl ErrorCode {
pub fn exit_code(&self) -> i32 {
match self {
Self::InternalError => 1,
Self::ConfigNotFound => 2,
Self::ConfigNotFound => 20,
Self::ConfigInvalid => 3,
Self::TokenNotSet => 4,
Self::GitLabAuthFailed => 5,
@@ -70,6 +74,8 @@ impl ErrorCode {
Self::OllamaUnavailable => 14,
Self::OllamaModelNotFound => 15,
Self::EmbeddingFailed => 16,
Self::NotFound => 17,
Self::Ambiguous => 18,
}
}
}
@@ -174,8 +180,8 @@ impl LoreError {
Self::Json(_) => ErrorCode::InternalError,
Self::Io(_) => ErrorCode::IoError,
Self::Transform(_) => ErrorCode::TransformError,
Self::NotFound(_) => ErrorCode::GitLabNotFound,
Self::Ambiguous(_) => ErrorCode::GitLabNotFound,
Self::NotFound(_) => ErrorCode::NotFound,
Self::Ambiguous(_) => ErrorCode::Ambiguous,
Self::Other(_) => ErrorCode::InternalError,
Self::OllamaUnavailable { .. } => ErrorCode::OllamaUnavailable,
Self::OllamaModelNotFound { .. } => ErrorCode::OllamaModelNotFound,