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
RegistryError
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).
PackageNotFound
HttpStatus
ApiResponse
ResponseTooLarge
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.
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
impl DepsError
Sourcepub const fn is_not_found(&self) -> bool
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());Sourcepub fn fetch_failure(&self) -> FetchFailure
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);Sourcepub const fn is_offline(&self) -> bool
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 Error for DepsError
impl Error for DepsError
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()