char/avril
(wip) why'd you have to go and make things so complicaaaaated?
git clone https://git.t4t.associates/char/avril
5e9a653
main
1use std:: sync:: Arc ; 2 3/// Failures acquiring, verifying, and resolving registry packages. 4/// 5/// Every variant preserves the historical message so lockfile, cache, and 6/// authority diagnostics stay stable; the structure lets callers match on 7/// failure kinds instead of substrings. 8# [ derive ( Clone , Debug , thiserror :: Error )] 9pub enum RegistryError { 10# [ error ( transparent )] 11Url ( # [ from ] url:: ParseError ), 12# [ error ( transparent )] 13Caps ( # [ from ] crate :: caps:: CapabilitiesError ), 14# [ error ( transparent )] 15Io ( Arc < std:: io:: Error >), 16# [ error ( transparent )] 17Json ( Arc < serde_json:: Error >), 18# [ error ( transparent )] 19Fjson ( # [ from ] serde_fjson:: Error ), 20# [ error ( transparent )] 21Hyper ( Arc < hyper:: Error >), 22// -- mod.rs: options and lockfile ------------------------------------- 23# [ error ( "Update and frozen-lock modes cannot be combined" )] 24UpdateAndFrozen , 25# [ error ( "npm project root must be an absolute path" )] 26NpmProjectRootNotAbsolute , 27# [ error ( "Frozen lockfile does not exist: {}" , path . display ())] 28FrozenLockfileDoesNotExist { path : std:: path:: PathBuf }, 29# [ error ( "HTTP package configs cannot use the configured JSR registry: {name}" )] 30HttpConfigUsesJsrRegistry { name : String }, 31# [ error ( "HTTP package configs cannot redirect into the configured JSR registry: {url}" )] 32HttpConfigRedirectsIntoJsr { url : String }, 33# [ error ( "Frozen lockfile is missing remote source: {name}" )] 34FrozenLockfileMissingRemote { name : String }, 35# [ error ( "Remote integrity or final URL mismatch: {name}" )] 36RemoteIntegrityMismatch { name : String }, 37# [ error ( "HTTP module was not acquired: {name}" )] 38HttpModuleNotAcquired { name : String }, 39# [ error ( "Cannot prune a frozen lockfile" )] 40PruneFrozen , 41# [ error ( "Lockfile changed concurrently for {key}" )] 42LockfileChanged { key : String }, 43# [ error ( "Locked metadata changed for {url}" )] 44LockedMetadataChanged { url : String }, 45# [ error ( "Locked npm package changed for {key}" )] 46LockedNpmPackageChanged { key : String }, 47# [ error ( "Locked npm instance changed for {id}" )] 48LockedNpmInstanceChanged { id : String }, 49# [ error ( "Missing acquired artifact while vendoring: {name}" )] 50MissingVendoredArtifact { name : String }, 51# [ error ( "npm instance registry mismatch: {package}" )] 52NpmInstanceRegistryMismatch { package : String }, 53# [ error ( "npm file integrity mismatch: {rel}" )] 54NpmFileIntegrityMismatch { rel : String }, 55# [ error ( "Offline package cache miss: {url}" )] 56OfflineCacheMiss { url : String }, 57# [ error ( "Registry returned {status} for {url}" )] 58RegistryStatus { status : String , url : String }, 59# [ error ( "Registry returned HTML instead of an artifact: {url}" )] 60RegistryHtmlArtifact { url : String }, 61# [ error ( "Registry artifact is too large: {url}" )] 62RegistryArtifactTooLarge { url : String }, 63# [ error ( "Registry request timed out: {url}" )] 64RegistryTimeout { url : String }, 65# [ error ( "Package integrity mismatch" )] 66IntegrityMismatch , 67# [ error ( "{name}: Package integrity mismatch" )] 68VerifyMismatch { name : String }, 69# [ error ( "Package artifacts must be regular files" )] 70ArtifactNotRegularFile , 71# [ error ( "Cached package artifact is too large" )] 72CachedArtifactTooLarge , 73# [ error ( "Lockfile must be a regular file" )] 74LockfileNotRegularFile , 75# [ error ( "{name}: not UTF-8" )] 76LockfileNotUtf8 { name : String }, 77# [ error ( "{detail}" )] 78LockfileParse { detail : String }, 79# [ error ( "{name}: {source}" )] 80LockfileJson { 81name : String , 82source : std:: sync:: Arc < serde_json:: Error >, 83}, 84# [ error ( "Registry must be an absolute base URL without credentials, query, or fragment" )] 85InvalidRegistryBaseUrl , 86# [ error ( "Lockfile is too large" )] 87LockfileTooLarge , 88# [ error ( "Lockfile needs a parent directory" )] 89LockfileNeedsParent , 90# [ error ( "Output needs a parent directory" )] 91OutputNeedsParent , 92# [ error ( "Registries require HTTPS (HTTP is allowed only for loopback testing)" )] 93RegistryRequiresHttps , 94# [ error ( "Unsupported lockfile version: {version}" )] 95UnsupportedLockfileVersion { version : u32 }, 96# [ error ( "Lockfile JSR registry does not match the configured JSR registry" )] 97LockfileJsrRegistryMismatch , 98# [ error ( "Lockfile version 1 cannot carry npm pins" )] 99LockfileV1NpmPins , 100# [ error ( "Lockfile npm registry does not match the configured npm registry" )] 101LockfileNpmRegistryMismatch , 102# [ error ( "Lockfile npm packages require an npm registry" )] 103LockfileNpmPackagesWithoutRegistry , 104# [ error ( "Registry module cannot use a remote lock entry: {name}" )] 105RegistryModuleRemoteLockEntry { name : String }, 106# [ error ( "{0} kept changing while it was being updated" )] 107FileKeptChanging ( String ), 108# [ error ( "Output must be a regular non-symlink file" )] 109OutputNotRegularFile , 110 111# [ error ( "Module is not UTF-8: {name}" )] 112ModuleNotUtf8 { name : String }, 113# [ error ( "HTTP acquisition worker stopped" )] 114HttpAcquisitionWorkerStopped , 115# [ error ( "Package acquisition worker stopped" )] 116PackageAcquisitionWorkerStopped , 117# [ error ( "{detail}" )] 118WorkerJoin { detail : String }, 119# [ error ( "{detail}" )] 120Persist { detail : String }, 121 122// -- sub-registry errors (each module's own type; transparent here) --- 123# [ error ( "{detail}" )] 124HttpRequest { detail : String }, 125# [ error ( transparent )] 126Http ( # [ from ] super :: http:: HttpError ), 127# [ error ( transparent )] 128Jsr ( # [ from ] super :: jsr:: JsrError ), 129# [ error ( transparent )] 130Npm ( # [ from ] super :: npm:: NpmError ), 131# [ error ( transparent )] 132NpmStorage ( # [ from ] super :: npm:: storage:: StorageError ), 133} 134// Explicit textual rendering for generic plumbing (such as update_file) 135// shared with callers that carry their own error types. Prefer carrying 136// RegistryError itself wherever possible. 137impl From < RegistryError > for String { 138fn from ( error : RegistryError ) ->Self { 139 error. to_string () 140} 141} 142 143impl From < std:: io:: Error > for RegistryError { 144fn from ( error : std:: io:: Error ) ->Self { 145Self :: Io ( Arc :: new ( error)) 146} 147} 148 149impl From < serde_json:: Error > for RegistryError { 150fn from ( error : serde_json:: Error ) ->Self { 151Self :: Json ( Arc :: new ( error)) 152} 153}