Skip to main content

Error

Enum Error 

Source
#[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),
}
Available on crate feature 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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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

§reference: String

The revision spec the caller supplied (e.g. HEAD, a SHA).

§reason: String

Backend-rendered explanation of why resolution failed.

§

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

Source

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 Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for Error

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more

Auto Trait Implementations§

§

impl Freeze for Error

§

impl RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

§

impl UnwindSafe for Error

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ErrorExt for T
where T: Error + Send + Sync + 'static,

Source§

fn raise(self) -> Exn<Self>
where Self: Sized,

Raise this error as a new exception.
Source§

fn and_raise<T>(self, context: T) -> Exn<T>
where T: Error + Send + Sync + 'static, Self: Sized,

Raise this error as a child of a new exception with the given context error. Read more
Source§

fn raise_erased(self) -> Exn
where Self: Sized,

Raise this error as a new exception, with type erasure.
Source§

fn raise_all<T, I>(self, sources: I) -> Exn<Self>
where Self: Sized, T: Error + Send + Sync + 'static, I: IntoIterator, <I as IntoIterator>::Item: Into<Exn<T>>,

Raise this error as a new exception, with sources as causes.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.