#[non_exhaustive]pub enum Error {
Show 17 variants
NotARepository(PathBuf),
OpenRepository(String),
ResolveRef {
reference: String,
reason: String,
},
Walk(String),
Diff(String),
Mailmap(String),
InvalidBotPattern(String),
InvalidWindow(String),
InvalidTimestamp(String),
InvalidFormula(String),
InvalidFileTypeScope(String),
InvalidBusFactorThreshold(String),
InvalidAuthorHashKey(String),
InvalidTrend(String),
Blame(String),
InvalidDiff(String),
Cache(String),
}vcs-git only.Expand description
Error returned by build_history_index
and the surrounding VCS pipeline.
#[non_exhaustive] so new variants land additively as backends and
edge cases accrue; match with a trailing _ arm to stay
forward-compatible.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
NotARepository(PathBuf)
The supplied path is not inside the working tree of any
supported VCS. Distinct from a repository with no tracked text
files at the target ref, which succeeds with an empty index. (A
freshly-initialised repository whose HEAD is unborn instead
surfaces as Error::ResolveRef, since there is no commit to
resolve.)
OpenRepository(String)
Opening or discovering the repository failed for a reason other than “no repository here” (corrupt repo, permission denied, …).
ResolveRef
The --ref revision could not be resolved to a commit.
Fields
Walk(String)
Walking commit history failed.
Diff(String)
Computing a tree-to-tree or blob diff failed.
Mailmap(String)
Loading or applying the repository .mailmap failed.
InvalidBotPattern(String)
The bot-exclusion pattern is not a valid regular expression.
InvalidWindow(String)
A configured time window could not be parsed.
InvalidTimestamp(String)
The --as-of timestamp could not be parsed.
InvalidFormula(String)
The risk-formula name is not one of weighted / percentile.
InvalidFileTypeScope(String)
The file-type scope could not be parsed: an empty value, or a custom extension list that normalised to nothing (issue #576).
InvalidBusFactorThreshold(String)
The bus-factor coverage threshold is outside the open interval
(0, 1) (issue #332).
InvalidAuthorHashKey(String)
The opt-in author-hash key is unusable — empty, or supplied
without --emit-author-details (which it has no effect without)
(issue #956).
InvalidTrend(String)
The historical-trend parameters are out of range — the point
count is below the two-point minimum or above
MAX_TREND_POINTS (issue
#333).
Blame(String)
Blaming a file for per-function attribution failed (issue #329).
InvalidDiff(String)
An arbitrary unified diff supplied to
score_diff could not be parsed (issue
#580). A client-input error: the diff was malformed (a hunk header
the parser could not read, a body line outside any hunk, …).
Cache(String)
Reading, writing, or clearing the persistent history cache failed
(issue #334). A missing or corrupt cache entry is not an error —
it is silently ignored and the history is recomputed — so this
variant is reserved for genuine I/O failures the caller asked to
surface (e.g. --clear-cache on an unwritable directory).
Implementations§
Source§impl Error
impl Error
Sourcepub fn is_client_input(&self) -> bool
pub fn is_client_input(&self) -> bool
Whether this error was caused by client-supplied input (a bad
path, revision, window, timestamp, formula, pattern, threshold,
trend parameter, file-type scope, or diff) as opposed to an
environment or backend failure (opening the repository, walking
history, diffing, .mailmap, blame, or the persistent cache).
Front ends use this to choose a status: a web boundary maps
client-input errors to 400 Bad Request and the rest to
500 Internal Server Error (see vcs_error_response in the web
crate).
The match is intentionally exhaustive (no wildcard arm): adding a
new Error variant is a compile error here until it is
classified, which prevents the silent fall-through that twice
mis-mapped client-input variants to 500 (InvalidFileTypeScope,
InvalidDiff; see issue #641).
Trait Implementations§
Source§impl Error for Error
impl Error for Error
1.30.0 · 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()