on master help sign in
add error messages for package problems
commit3b177fe62eb431482ad635291731ab38d6dbaf28 authorEvan Czaplicki <evancz@users.noreply.github.com> dateTue 18 Jun 2019, 17:10 (7 years ago) parent4795a82
2 files changed+71−10
builder/src/Elm/Details.hs+8−5 builder/src/Reporting/Exit.hs+63−5
builder/src/Elm/Details.hs+8−5
@@ -725,24 +725,27 @@ toDocs result =
725725
726726downloadPackage :: Stuff.PackageCache -> Http.Manager -> Pkg.Name -> V.Version -> IO (Either Exit.PackageProblem ())
727727downloadPackage cache manager pkg vsn =
728+ let
729+ url = Website.metadata pkg vsn "endpoint.json"
730+ in
728731 do eitherByteString <-
729− Http.get manager (Website.metadata pkg vsn "endpoint.json") [] id (return . Right)
732+ Http.get manager url [] id (return . Right)
730733
731734 case eitherByteString of
732735 Left err ->
733− return (Left (Exit.PP_BadEndpointRequest err))
736+ return $ Left $ Exit.PP_BadEndpointRequest err
734737
735738 Right byteString ->
736739 case D.fromByteString endpointDecoder byteString of
737740 Left _ ->
738− return (Left Exit.PP_BadEndpointContent)
741+ return $ Left $ Exit.PP_BadEndpointContent url
739742
740743 Right (endpoint, expectedHash) ->
741− Http.getArchive manager endpoint Exit.PP_BadArchiveRequest Exit.PP_BadArchiveContent $
744+ Http.getArchive manager endpoint Exit.PP_BadArchiveRequest (Exit.PP_BadArchiveContent endpoint) $
742745 \(sha, archive) ->
743746 if expectedHash == Http.shaToChars sha
744747 then Right <$> File.writePackage (Stuff.package cache pkg vsn) archive
745− else return $ Left $ Exit.PP_BadArchiveHash expectedHash (Http.shaToChars sha)
748+ else return $ Left $ Exit.PP_BadArchiveHash endpoint expectedHash (Http.shaToChars sha)
746749
747750
748751endpointDecoder :: D.Decoder e (String, String)
builder/src/Reporting/Exit.hs+63−5
@@ -1145,8 +1145,8 @@ toDetailsReport details =
11451145 toRegistryProblemReport "PROBLEM LOADING PACKAGE LIST" problem $
11461146 "I need the list of published packages to figure out if your project has compatible dependencies"
11471147
1148− DetailsCannotBuildPackage name version problem ->
1149− error "TODO DetailsCannotBuildPackage" name version problem
1148+ DetailsCannotBuildPackage pkg vsn problem ->
1149+ toPackageProblemReport pkg vsn problem
11501150
11511151
11521152
@@ -1155,10 +1155,68 @@ toDetailsReport details =
11551155
11561156data PackageProblem
11571157 = PP_BadEndpointRequest Http.Error
1158− | PP_BadEndpointContent
1158+ | PP_BadEndpointContent String
11591159 | PP_BadArchiveRequest Http.Error
1160− | PP_BadArchiveContent
1161− | PP_BadArchiveHash String String
1160+ | PP_BadArchiveContent String
1161+ | PP_BadArchiveHash String String String
1162+
1163+
1164+toPackageProblemReport :: Pkg.Name -> V.Version -> PackageProblem -> Help.Report
1165+toPackageProblemReport pkg vsn problem =
1166+ let
1167+ thePackage =
1168+ Pkg.toChars pkg ++ " " ++ V.toChars vsn
1169+ in
1170+ case problem of
1171+ PP_BadEndpointRequest httpError ->
1172+ toHttpErrorReport "PROBLEM DOWNLOADING PACKAGE" httpError $
1173+ "I need to find the latest download link for " ++ thePackage
1174+
1175+ PP_BadEndpointContent url ->
1176+ Help.report "PROBLEM DOWNLOADING PACKAGE" Nothing
1177+ (
1178+ "I need to find the latest download link for " ++ thePackage ++ ", but I ran into corrupted information from:"
1179+ )
1180+ [ D.indent 4 $ D.dullyellow $ D.fromChars url
1181+ , D.reflow $
1182+ "Is something weird with your internet connection. We have gotten reports that\
1183+ \ schools, businesses, airports, etc. sometimes intercept requests and add things\
1184+ \ to the body or change its contents entirely. Could that be the problem?"
1185+ ]
1186+
1187+ PP_BadArchiveRequest httpError ->
1188+ toHttpErrorReport "PROBLEM DOWNLOADING PACKAGE" httpError $
1189+ "I was trying to download the source code for " ++ thePackage
1190+
1191+ PP_BadArchiveContent url ->
1192+ Help.report "PROBLEM DOWNLOADING PACKAGE" Nothing
1193+ (
1194+ "I downloaded the source code for " ++ thePackage ++ " from:"
1195+ )
1196+ [ D.indent 4 $ D.dullyellow $ D.fromChars url
1197+ , D.reflow $
1198+ "But I was unable to unzip the data. Maybe there is something weird with\
1199+ \ your internet connection. We have gotten reports that schools, businesses,\
1200+ \ airports, etc. sometimes intercept requests and add things to the body or\
1201+ \ change its contents entirely. Could that be the problem?"
1202+ ]
1203+
1204+ PP_BadArchiveHash url expectedHash actualHash ->
1205+ Help.report "CORRUPT PACKAGE DATA" Nothing
1206+ (
1207+ "I downloaded the source code for " ++ thePackage ++ " from:"
1208+ )
1209+ [ D.indent 4 $ D.dullyellow $ D.fromChars url
1210+ , D.reflow "But it looks like the hash of the archive has changed since publication:"
1211+ , D.vcat $ map D.fromChars $
1212+ [ " Expected: " ++ expectedHash
1213+ , " Actual: " ++ actualHash
1214+ ]
1215+ , D.reflow $
1216+ "This usually means that the package author moved the version\
1217+ \ tag, so report it to them and see if that is the issue. Folks\
1218+ \ on Elm slack can probably help as well."
1219+ ]
11621220
11631221
11641222