Skip to main content

github_rate_limit_error

Function github_rate_limit_error 

Source
pub fn github_rate_limit_error(verified: RateLimitEvidence) -> DepsError
Expand description

The actionable error returned when a request hits GitHub’s rate limit.

Either a 403 inferred from status and the absence of a token alone (verified: RateLimitEvidence::Inferred), or one crate::cache already confirmed via response evidence (verified: RateLimitEvidence::Confirmed, #1295).

A single fn(RateLimitEvidence) (#1480 item 8), not the two separate github_rate_limit_error/github_rate_limit_error_verified constructors this replaced: the only difference between the two was which message/verified pair to use, so every caller had to duplicate an if verified { .. } else { .. } branch — see crate::rate_limit::RateLimitGate::evidence for the matching gate-side projection.

pub, not pub(crate): needed both by classify_tags_fetch_error (this crate) and by deps_github_actions::registry::GithubActionsRegistry’s rate-limit-gate short-circuit (critic S3), which must replay the same verified state a gate was tripped with rather than always reporting an unverified guess.

§Examples

use deps_core::RateLimitEvidence;
use deps_core::github::github_rate_limit_error;

let err = github_rate_limit_error(RateLimitEvidence::Confirmed);
assert!(err.to_string().contains("GITHUB_TOKEN"));