packages feed

pantry 0.7.0 → 0.7.1

raw patch · 6 files changed

+299/−158 lines, 6 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -1,5 +1,12 @@ # Changelog for pantry
 
+## v0.7.1
+
+* To support the Haskell Foundation's
+  [Haskell Error Index](https://errors.haskell.org/) initiative, all Pantry
+  error messages generated by Pantry itself begin with an unique code in the
+  form `[S-nnn]`, where `nnn` is a three-digit number.
+
 ## v0.7.0
 
 * Change `defaultHackageSecurityConfig` such that field
pantry.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack
 
 name:           pantry
-version:        0.7.0
+version:        0.7.1
 synopsis:       Content addressable Haskell package management
 description:    Please see the README on GitHub at <https://github.com/commercialhaskell/pantry#readme>
 category:       Development
src/Pantry.hs view
@@ -1772,7 +1772,11 @@       eres <- tryAny (inner2 dest)
       mres <-
         case eres of
-          Left e -> Nothing <$ logError ("Error when parsing global hints: " <> displayShow e)
+          Left e -> Nothing <$ logError
+                                 ( "Error: [S-912]\n"
+                                   <> "Error when parsing global hints: "
+                                   <> displayShow e
+                                 )
           Right x -> pure x
       case mres of
         Nothing | not alreadyDownloaded && not downloaded -> do
src/Pantry/Hackage.hs view
@@ -307,10 +307,11 @@     addJSON name version lbs =
       case eitherDecode' lbs of
         Left e -> lift $ logError $
-          "Error processing Hackage security metadata for " <>
-          fromString (Distribution.Text.display name) <> "-" <>
-          fromString (Distribution.Text.display version) <> ": " <>
-          fromString e
+          "Error: [S-563]\n"
+          <> "Error processing Hackage security metadata for "
+          <> fromString (Distribution.Text.display name) <> "-"
+          <> fromString (Distribution.Text.display version) <> ": "
+          <> fromString e
         Right (PackageDownload sha size) ->
           storeHackageTarballInfo name version sha $ FileSize size
 
src/Pantry/SHA256.hs view
@@ -172,14 +172,22 @@ instance Exception SHA256Exception
 instance Show SHA256Exception where
   show = T.unpack . utf8BuilderToText . display
+
+-- To support the Haskell Foundation's
+-- [Haskell Error Index](https://errors.haskell.org/) initiative, all Pantry
+-- error messages generated by Pantry itself begin with an unique code in the
+-- form `[S-nnn]`, where `nnn` is a three-digit number in the range 100 to 999.
+-- The numbers are selected at random, not in sequence.
 instance Display SHA256Exception where
   display (InvalidByteCount bs sbe) =
-    "Invalid byte count creating a SHA256 from " <>
-    displayShow bs <>
-    ": " <>
-    displayShow sbe
+    "Error: [S-161]\n"
+    <> "Invalid byte count creating a SHA256 from "
+    <> displayShow bs
+    <> ": "
+    <> displayShow sbe
   display (InvalidHexBytes bs t) =
-    "Invalid hex bytes creating a SHA256: " <>
-    displayShow bs <>
-    ": " <>
-    display t
+    "Error: [S-165]\n"
+    <> "Invalid hex bytes creating a SHA256: "
+    <> displayShow bs
+    <> ": "
+    <> display t
src/Pantry/Types.hs view
@@ -975,186 +975,307 @@ instance Exception PantryException where
 instance Show PantryException where
   show = T.unpack . utf8BuilderToText . display
+
+-- To support the Haskell Foundation's
+-- [Haskell Error Index](https://errors.haskell.org/) initiative, all Pantry
+-- error messages generated by Pantry itself begin with an unique code in the
+-- form `[S-nnn]`, where `nnn` is a three-digit number in the range 100 to 999.
+-- The numbers are selected at random, not in sequence.
 instance Display PantryException where
-  display (InvalidTreeFromCasa blobKey _bs) = "Invalid tree from casa: " <> display blobKey
+  display (InvalidTreeFromCasa blobKey _bs) =
+    "Error: [S-258]\n"
+    <> "Invalid tree from casa: "
+    <> display blobKey
   display (PackageIdentifierRevisionParseFail text) =
-    "Invalid package identifier (with optional revision): " <>
-    display text
+    "Error: [S-360]\n"
+    <> "Invalid package identifier (with optional revision): "
+    <> display text
   display (InvalidCabalFile loc mversion errs warnings) =
-    "Unable to parse cabal file from package " <>
-    either display (fromString . toFilePath) loc <>
-    "\n\n" <>
-    foldMap
-      (\(PError pos msg) ->
-          "- " <>
-          fromString (showPos pos) <>
-          ": " <>
-          fromString msg <>
-          "\n")
-      errs <>
-    foldMap
-      (\(PWarning _ pos msg) ->
-          "- " <>
-          fromString (showPos pos) <>
-          ": " <>
-          fromString msg <>
-          "\n")
-      warnings <>
-
-    (case mversion of
-       Just version
-         | version > cabalSpecLatestVersion ->
-             "\n\nThe cabal file uses the cabal specification version " <>
-             fromString (versionString version) <>
-             ", but we only support up to version " <>
-             fromString (versionString cabalSpecLatestVersion) <>
-             ".\nRecommended action: upgrade your build tool (e.g., `stack upgrade`)."
-       _ -> mempty)
-  display (TreeWithoutCabalFile pl) = "No cabal file found for " <> display pl
+    "Error: [S-242]\n"
+    <> "Unable to parse cabal file from package "
+    <> either display (fromString . toFilePath) loc
+    <> "\n\n"
+    <> foldMap
+         ( \(PError pos msg) ->
+                 "- "
+              <> fromString (showPos pos)
+              <> ": "
+              <> fromString msg
+              <> "\n"
+         )
+         errs
+    <> foldMap
+         ( \(PWarning _ pos msg) ->
+                 "- "
+              <> fromString (showPos pos)
+              <> ": "
+              <> fromString msg
+              <> "\n"
+         )
+         warnings
+    <> ( case mversion of
+           Just version
+             | version > cabalSpecLatestVersion ->
+                    "\n\nThe cabal file uses the cabal specification version "
+                 <> fromString (versionString version)
+                 <> ", but we only support up to version "
+                 <> fromString (versionString cabalSpecLatestVersion)
+                 <> ".\nRecommended action: upgrade your build tool (e.g., `stack upgrade`)."
+           _ -> mempty
+       )
+  display (TreeWithoutCabalFile pl) =
+    "Error: [S-654]\n"
+    <> "No cabal file found for "
+    <> display pl
   display (TreeWithMultipleCabalFiles pl sfps) =
-    "Multiple cabal files found for " <> display pl <> ": " <>
-    fold (intersperse ", " (map display sfps))
+    "Error: [S-500]\n"
+    <> "Multiple cabal files found for "
+    <> display pl
+    <> ": "
+    <> fold (intersperse ", " (map display sfps))
   display (MismatchedCabalName fp name) =
-    "cabal file path " <>
-    fromString (toFilePath fp) <>
-    " does not match the package name it defines.\n" <>
-    "Please rename the file to: " <>
-    fromString (packageNameString name) <>
-    ".cabal\n" <>
-    "For more information, see: https://github.com/commercialhaskell/stack/issues/317"
+    "Error: [S-910]\n"
+    <> "cabal file path "
+    <> fromString (toFilePath fp)
+    <> " does not match the package name it defines.\n"
+    <> "Please rename the file to: "
+    <> fromString (packageNameString name)
+    <> ".cabal\n"
+    <> "For more information, see: https://github.com/commercialhaskell/stack/issues/317"
   display (NoCabalFileFound dir) =
-    "Stack looks for packages in the directories configured in\n" <>
-    "the 'packages' and 'extra-deps' fields defined in your stack.yaml\n" <>
-    "The current entry points to " <>
-    fromString (toFilePath dir) <>
-    ",\nbut no .cabal or package.yaml file could be found there."
+    "Error: [S-636]\n"
+    <> "Stack looks for packages in the directories configured in\n"
+    <> "the 'packages' and 'extra-deps' fields defined in your stack.yaml\n"
+    <> "The current entry points to "
+    <> fromString (toFilePath dir)
+    <> ",\nbut no .cabal or package.yaml file could be found there."
   display (MultipleCabalFilesFound dir files) =
-    "Multiple .cabal files found in directory " <>
-    fromString (toFilePath dir) <>
-    ":\n" <>
-    fold (intersperse "\n" (map (\x -> "- " <> fromString (toFilePath (filename x))) files))
-  display (InvalidWantedCompiler t) = "Invalid wanted compiler: " <> display t
+    "Error: [S-368]\n"
+    <> "Multiple .cabal files found in directory "
+    <> fromString (toFilePath dir)
+    <> ":\n"
+    <> fold
+         ( intersperse
+             "\n"
+             (map (\x -> "- " <> fromString (toFilePath (filename x))) files)
+         )
+  display (InvalidWantedCompiler t) =
+    "Error: [S-204]\n"
+    <> "Invalid wanted compiler: "
+    <> display t
   display (InvalidSnapshotLocation dir t) =
-    "Invalid snapshot location " <>
-    displayShow t <>
-    " relative to directory " <>
-    displayShow (toFilePath dir)
+    "Error: [S-935]\n"
+    <> "Invalid snapshot location "
+    <> displayShow t
+    <> " relative to directory "
+    <> displayShow (toFilePath dir)
   display (InvalidOverrideCompiler x y) =
-    "Specified compiler for a resolver (" <>
-    display x <>
-    "), but also specified an override compiler (" <>
-    display y <>
-    ")"
+    "Error: [S-287]\n"
+    <> "Specified compiler for a resolver ("
+    <> display x
+    <> "), but also specified an override compiler ("
+    <> display y
+    <> ")"
   display (InvalidFilePathSnapshot t) =
-    "Specified snapshot as file path with " <>
-    displayShow t <>
-    ", but not reading from a local file"
+    "Error: [S-617]\n"
+    <> "Specified snapshot as file path with "
+    <> displayShow t
+    <> ", but not reading from a local file"
   display (InvalidSnapshot loc e) =
-    "Exception while reading snapshot from " <>
-    display loc <>
-    ":\n" <>
-    displayShow e
+    "Error: [S-775]\n"
+    <> "Exception while reading snapshot from "
+    <> display loc
+    <> ":\n"
+    <> displayShow e
   display (MismatchedPackageMetadata loc pm mtreeKey foundIdent) =
-    "Mismatched package metadata for " <> display loc <>
-    "\nFound: " <> fromString (packageIdentifierString foundIdent) <>
-    (case mtreeKey of
-       Nothing -> mempty
-       Just treeKey -> " with tree " <> display treeKey) <>
-    "\nExpected: " <> display pm
+    "Error: [S-427]\n"
+    <> "Mismatched package metadata for "
+    <> display loc
+    <> "\nFound: "
+    <> fromString (packageIdentifierString foundIdent)
+    <> ( case mtreeKey of
+           Nothing -> mempty
+           Just treeKey -> " with tree " <> display treeKey
+       )
+    <> "\nExpected: "
+    <> display pm
   display (Non200ResponseStatus status) =
-    "Unexpected non-200 HTTP status code: " <>
-    displayShow (statusCode status)
+    "Error: [S-571]\n"
+    <> "Unexpected non-200 HTTP status code: "
+    <> displayShow (statusCode status)
   display (InvalidBlobKey Mismatch{..}) =
-    "Invalid blob key found, expected: " <>
-    display mismatchExpected <>
-    ", actual: " <>
-    display mismatchActual
+    "Error: [S-236]\n"
+    <> "Invalid blob key found, expected: "
+    <> display mismatchExpected
+    <> ", actual: "
+    <> display mismatchActual
   display (Couldn'tParseSnapshot sl e) =
-    "Couldn't parse snapshot from " <> display sl <> ": " <> fromString e
+    "Error: [S-645]\n"
+    <> "Couldn't parse snapshot from "
+    <> display sl
+    <> ": "
+    <> fromString e
   display (WrongCabalFileName pl sfp name) =
-    "Wrong cabal file name for package " <> display pl <>
-    "\nThe cabal file is named " <> display sfp <>
-    ", but package name is " <> fromString (packageNameString name) <>
-    "\nFor more information, see:\n  - https://github.com/commercialhaskell/stack/issues/317\n  -https://github.com/commercialhaskell/stack/issues/895"
+    "Error: [S-575]\n"
+    <> "Wrong cabal file name for package "
+    <> display pl
+    <> "\nThe cabal file is named "
+    <> display sfp
+    <> ", but package name is "
+    <> fromString (packageNameString name)
+    <> "\nFor more information, see:\n  - https://github.com/commercialhaskell/stack/issues/317\n  -https://github.com/commercialhaskell/stack/issues/895"
   display (DownloadInvalidSHA256 url Mismatch {..}) =
-    "Mismatched SHA256 hash from " <> display url <>
-    "\nExpected: " <> display mismatchExpected <>
-    "\nActual:   " <> display mismatchActual
+    "Error: [S-394]\n"
+    <> "Mismatched SHA256 hash from "
+    <> display url
+    <> "\nExpected: "
+    <> display mismatchExpected
+    <> "\nActual:   "
+    <> display mismatchActual
   display (DownloadInvalidSize url Mismatch {..}) =
-    "Mismatched download size from " <> display url <>
-    "\nExpected: " <> display mismatchExpected <>
-    "\nActual:   " <> display mismatchActual
+    "Error: [S-401]\n"
+    <> "Mismatched download size from "
+    <> display url
+    <> "\nExpected: "
+    <> display mismatchExpected
+    <> "\nActual:   "
+    <> display mismatchActual
   display (DownloadTooLarge url Mismatch {..}) =
-    "Download from " <> display url <> " was too large.\n" <>
-    "Expected: " <> display mismatchExpected <> ", stopped after receiving: " <>
-    display mismatchActual
+    "Error: [S-113]\n"
+    <> "Download from "
+    <> display url
+    <> " was too large.\n"
+    <> "Expected: "
+    <> display mismatchExpected
+    <> ", stopped after receiving: "
+    <> display mismatchActual
   display (LocalInvalidSHA256 path Mismatch {..}) =
-    "Mismatched SHA256 hash from " <> fromString (toFilePath path) <>
-    "\nExpected: " <> display mismatchExpected <>
-    "\nActual:   " <> display mismatchActual
+    "Error: [S-834]\n"
+    <> "Mismatched SHA256 hash from "
+    <> fromString (toFilePath path)
+    <> "\nExpected: "
+    <> display mismatchExpected
+    <> "\nActual:   "
+    <> display mismatchActual
   display (LocalInvalidSize path Mismatch {..}) =
-    "Mismatched file size from " <> fromString (toFilePath path) <>
-    "\nExpected: " <> display mismatchExpected <>
-    "\nActual:   " <> display mismatchActual
-  display (UnknownArchiveType loc) = "Unable to determine archive type of: " <> display loc
+    "Error: [S-713]\n"
+    <> "Mismatched file size from "
+    <> fromString (toFilePath path)
+    <> "\nExpected: "
+    <> display mismatchExpected
+    <> "\nActual:   "
+    <> display mismatchActual
+  display (UnknownArchiveType loc) =
+    "Error: [S-372]\n"
+    <> "Unable to determine archive type of: "
+    <> display loc
   display (InvalidTarFileType loc fp x) =
-    "Unsupported tar file type in archive " <> display loc <> " at file " <> fromString fp <> ": " <> displayShow x
+    "Error: [S-950]\n"
+    <> "Unsupported tar file type in archive "
+    <> display loc
+    <> " at file "
+    <> fromString fp
+    <> ": "
+    <> displayShow x
   display (UnsupportedTarball loc e) =
-    "Unsupported tarball from " <> display loc <> ": " <> display e
+    "Error: [S-760]\n"
+    <> "Unsupported tarball from "
+    <> display loc
+    <> ": "
+    <> display e
   display (NoHackageCryptographicHash ident) =
-    "No cryptographic hash found for Hackage package " <> fromString (packageIdentifierString ident)
-  display (FailedToCloneRepo repo) = "Failed to clone repo " <> display repo
+    "Error: [S-922]\n"
+    <> "No cryptographic hash found for Hackage package "
+    <> fromString (packageIdentifierString ident)
+  display (FailedToCloneRepo repo) =
+    "Error: [S-109]\n"
+    <> "Failed to clone repo "
+    <> display repo
   display (TreeReferencesMissingBlob loc sfp key) =
-    "The package " <> display loc <>
-    " needs blob " <> display key <>
-    " for file path " <> display sfp <>
-    ", but the blob is not available"
+    "Error: [S-237]\n"
+    <> "The package "
+    <> display loc
+    <> " needs blob "
+    <> display key
+    <> " for file path "
+    <> display sfp
+    <> ", but the blob is not available"
   display (CompletePackageMetadataMismatch loc pm) =
-    "When completing package metadata for " <> display loc <>
-    ", some values changed in the new package metadata: " <>
-    display pm
+    "Error: [S-984]\n"
+    <> "When completing package metadata for "
+    <> display loc
+    <> ", some values changed in the new package metadata: "
+    <> display pm
   display (CRC32Mismatch loc fp Mismatch {..}) =
-    "CRC32 mismatch in ZIP file from " <> display loc <>
-    " on internal file " <> fromString fp <>
-    "\nExpected: " <> display mismatchExpected <>
-    "\nActual:   " <> display mismatchActual
+    "Error: [S-607]\n"
+    <> "CRC32 mismatch in ZIP file from "
+    <> display loc
+    <> " on internal file "
+    <> fromString fp
+    <> "\nExpected: "
+    <> display mismatchExpected
+    <> "\nActual:   "
+    <> display mismatchActual
   display (UnknownHackagePackage pir fuzzy) =
-    "Could not find " <> display pir <> " on Hackage" <>
-    displayFuzzy fuzzy
+    "Error: [S-476]\n"
+    <> "Could not find "
+    <> display pir
+    <> " on Hackage"
+    <> displayFuzzy fuzzy
   display (CannotCompleteRepoNonSHA1 repo) =
-    "Cannot complete repo information for a non SHA1 commit due to non-reproducibility: " <>
-    display repo
+    "Error: [S-112]\n"
+    <> "Cannot complete repo information for a non SHA1 commit due to non-reproducibility: "
+    <> display repo
   display (MutablePackageLocationFromUrl t) =
-    "Cannot refer to a mutable package location from a URL: " <> display t
+    "Error: [S-321]\n"
+    <> "Cannot refer to a mutable package location from a URL: "
+    <> display t
   display (MismatchedCabalFileForHackage pir Mismatch{..}) =
-    "When processing cabal file for Hackage package " <> display pir <>
-    ":\nMismatched package identifier." <>
-    "\nExpected: " <> fromString (packageIdentifierString mismatchExpected) <>
-    "\nActual:   " <> fromString (packageIdentifierString mismatchActual)
+    "Error: [S-377]\n"
+    <> "When processing cabal file for Hackage package "
+    <> display pir
+    <> ":\nMismatched package identifier."
+    <> "\nExpected: "
+    <> fromString (packageIdentifierString mismatchExpected)
+    <> "\nActual:   "
+    <> fromString (packageIdentifierString mismatchActual)
   display (PackageNameParseFail t) =
-    "Invalid package name: " <> display t
+    "Error: [S-580]\n"
+    <> "Invalid package name: "
+    <> display t
   display (PackageVersionParseFail t) =
-    "Invalid version: " <> display t
+    "Error: [S-479]\n"
+    <> "Invalid version: "
+    <> display t
   display (InvalidCabalFilePath fp) =
-    "File path contains a name which is not a valid package name: " <>
-    fromString (toFilePath fp)
+    "Error: [S-824]\n"
+    <> "File path contains a name which is not a valid package name: "
+    <> fromString (toFilePath fp)
   display (DuplicatePackageNames source pairs') =
-    "Duplicate package names (" <> source <> "):\n" <>
-    foldMap
-      (\(name, locs) ->
-        fromString (packageNameString name) <> ":\n" <>
-        foldMap
-          (\loc -> "- " <> display loc <> "\n")
-          locs
-      )
-      pairs'
+    "Error: [S-674]\n"
+    <> "Duplicate package names ("
+    <> source
+    <> "):\n"
+    <> foldMap
+         ( \(name, locs) ->
+                fromString (packageNameString name)
+             <> ":\n"
+             <> foldMap (\loc -> "- " <> display loc <> "\n") locs
+         )
+         pairs'
   display (MigrationFailure desc fp ex) =
-    "Encountered error while migrating " <> display desc <> " database:" <>
-    "\n    " <> displayShow ex <>
-    "\nPlease report this on https://github.com/commercialhaskell/stack/issues" <>
-    "\nAs a workaround you may delete " <> display desc <> " database in " <>
-    fromString (toFilePath fp) <> " triggering its recreation."
-  display (ParseSnapNameException t) = "Invalid snapshot name: " <> display t
+    "Error: [S-536]\n"
+    <> "Encountered error while migrating database "
+    <> display desc
+    <> "\nlocated at "
+    <> fromString (toFilePath fp)
+    <> ":"
+    <> "\n    "
+    <> displayShow ex
+  display (ParseSnapNameException t) =
+    "Error: [S-994]\n"
+     <> "Invalid snapshot name: "
+     <> display t
 
 data FuzzyResults
   = FRNameNotFound ![PackageName]