Skip to main content

DepsError

Enum DepsError 

Source
pub enum DepsError {
Show 16 variants ParseError { file_type: String, source: Box<dyn Error + Send + Sync>, }, RegistryError { package: String, source: Error, }, CacheError(String), RateLimited { message: String, }, PackageNotFound { package: String, registry: &'static str, }, HttpStatus { url: String, status: u16, }, ApiResponse { package: String, registry: &'static str, source: Error, }, ResponseTooLarge { url: String, limit: usize, }, InvalidVersionReq(String), Io(Error), Json(Error), UnsupportedEcosystem(String), AmbiguousEcosystem(String), InvalidUri(String), Offline { url: String, }, ChainResolutionHalted,
}
Expand description

Core error types for deps-lsp.

Extended from Phase 1 to support multiple ecosystems (Cargo, npm, PyPI). All errors provide structured error handling with source error tracking.

§Examples

use deps_core::error::{DepsError, Result};

fn parse_file(content: &str, file_type: &str) -> Result<()> {
    // Parsing errors are automatically wrapped
    if content.is_empty() {
        return Err(DepsError::ParseError {
            file_type: file_type.into(),
            source: Box::new(std::io::Error::new(
                std::io::ErrorKind::InvalidData,
                "empty content"
            )),
        });
    }
    Ok(())
}

Variants§

§

ParseError

Fields

§file_type: String
§source: Box<dyn Error + Send + Sync>
§

RegistryError

Fields

§package: String
§source: Error
§

CacheError(String)

§

RateLimited

A registry request was rejected for exceeding a rate limit. Unlike other variants, message is a pre-vetted, IP-free, actionable hint safe to surface verbatim in a per-dependency diagnostic (see Self::fetch_failure) — never build one from a raw registry error body, which can embed the caller’s public IP (github.rs:332-346).

Fields

§message: String
§

PackageNotFound

Fields

§package: String
§registry: &'static str
§

HttpStatus

Fields

§status: u16
§

ApiResponse

Fields

§package: String
§registry: &'static str
§source: Error
§

ResponseTooLarge

Fields

§limit: usize
§

InvalidVersionReq(String)

Deliberately shared between two distinct rejection kinds: malformed version-requirement strings (all ecosystems) and malformed Go module paths (deps-go, which has no separate variant for the latter — see its validate_module_path). Nothing in the workspace discriminates on this variant beyond rendering its message, so a consumer-specific split was deferred (#399).

§

Io(Error)

§

Json(Error)

§

UnsupportedEcosystem(String)

§

AmbiguousEcosystem(String)

§

InvalidUri(String)

§

Offline

Returned by deps_core::cache::HttpCache’s 4 send sites (issue #483) when network.offline is set, instead of attempting the request. url is the request that was blocked, for diagnostic/logging purposes.

Fields

§

ChainResolutionHalted

A multi-hop alternate/private-index chain’s resolution was halted because a hop returned a genuine transport error (5xx, timeout, connection failure) rather than a clean “not found” — the chain deliberately does not fall through to a further, less trusted hop in this case (deps_pypi’s FR-005(c)/NFR-003(3), #513). Carries no arbitrary error text — mirrors Self::RateLimited’s pre-vetted-message precedent (see Self::fetch_failure’s security-load-bearing invariant) — so its classification there can safely be FetchFailure::Actionable with a fixed, safe message, surfacing this case in hover/diagnostics instead of only a tracing::warn!.

Implementations§

Source§

impl DepsError

Source

pub const fn is_not_found(&self) -> bool

Returns true when this error means the registry was successfully asked and answered “this package doesn’t exist”, as opposed to the registry not having been answerable at all (network failure, timeout, malformed response, 5xx).

Distinguishing the two matters for diagnostics (#267): a genuine not-found is evidence the package name is wrong, while any other error is evidence only that this particular request failed — reporting the latter as “Unknown package” would mislabel a transient registry outage as a nonexistent dependency. Covers DepsError::PackageNotFound (the ecosystems that map a 404 to it explicitly: npm, PyPI, Go, Swift) and a bare DepsError::HttpStatus with status == 404 (the ecosystems that propagate the raw HTTP status instead: Cargo, Maven, Gradle, Bundler, Dart, Composer, NuGet).

§Examples
use deps_core::DepsError;

let not_found = DepsError::PackageNotFound {
    package: "left-pad".into(),
    registry: "npm",
};
assert!(not_found.is_not_found());

let http_404 = DepsError::HttpStatus {
    url: "https://crates.io/api/v1/crates/left-pad".into(),
    status: 404,
};
assert!(http_404.is_not_found());

let outage = DepsError::HttpStatus {
    url: "https://crates.io/api/v1/crates/serde".into(),
    status: 503,
};
assert!(!outage.is_not_found());

let cache_err = DepsError::CacheError("connection reset".into());
assert!(!cache_err.is_not_found());
Source

pub fn fetch_failure(&self) -> FetchFailure

Classifies this error for the per-dependency “registry lookup failed” diagnostic (#478), distinguishing a failure with a safe, actionable hint to show the user from one whose raw text must never reach a diagnostic.

Security-load-bearing invariant: FetchFailure::Actionable is produced only from Self::RateLimited’s pre-vetted, IP-free canned message. Every other variant must classify as FetchFailure::Transient — never call .to_string()/Display on an arbitrary DepsError to build an Actionable value, since a raw HttpStatus or RegistryError body can embed the caller’s public IP (github.rs:332-346, exercised by the github crate’s test_parse_tags_page_github_rate_limit_returns_error).

§Examples
use deps_core::error::{DepsError, FetchFailure};

let rate_limited = DepsError::RateLimited { message: "set GITHUB_TOKEN".into() };
assert_eq!(
    rate_limited.fetch_failure(),
    FetchFailure::Actionable("set GITHUB_TOKEN".into())
);

let other = DepsError::CacheError("connection reset".into());
assert_eq!(other.fetch_failure(), FetchFailure::Transient);
Source

pub const fn is_offline(&self) -> bool

Returns true when this error means a request was blocked by network.offline (issue #483), as opposed to any other network or registry failure.

Used by deps_maven::registry to skip poisoning its negative-search-failure cache with an offline block, so toggling network.offline back to false takes effect immediately instead of being masked by RECENT_FAILURE_TTL.

§Examples
use deps_core::DepsError;

let offline = DepsError::Offline { url: "https://crates.io/".into() };
assert!(offline.is_offline());

let other = DepsError::CacheError("connection reset".into());
assert!(!other.is_offline());

Trait Implementations§

Source§

impl Debug for DepsError

Source§

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

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

impl Display for DepsError

Source§

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

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

impl Error for DepsError

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
Source§

impl From<Error> for DepsError

Source§

fn from(source: Error) -> DepsError

Converts to this type from the input type.
Source§

impl From<Error> for DepsError

Source§

fn from(source: Error) -> DepsError

Converts to this type from the input type.

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more