on master help sign in
add error messages for package problems
3b177feEvan Czaplicki
builder/src/Elm/Details.hs+8−5
@@ -725,24 +725,27 @@ toDocs result =
725
725
726downloadPackage :: Stuff.PackageCache -> Http.Manager -> Pkg.Name -> V.Version -> IO (Either Exit.PackageProblem ())
726downloadPackage :: Stuff.PackageCache -> Http.Manager -> Pkg.Name -> V.Version -> IO (Either Exit.PackageProblem ())
727downloadPackage cache manager pkg vsn =
727downloadPackage cache manager pkg vsn =
728+ let
729+ url = Website.metadata pkg vsn "endpoint.json"
730+ in
728 do eitherByteString <-
731 do eitherByteString <-
729− Http.get manager (Website.metadata pkg vsn "endpoint.json") [] id (return . Right)
732+ Http.get manager url [] id (return . Right)
730
733
731 case eitherByteString of
734 case eitherByteString of
732 Left err ->
735 Left err ->
733− return (Left (Exit.PP_BadEndpointRequest err))
736+ return $ Left $ Exit.PP_BadEndpointRequest err
734
737
735 Right byteString ->
738 Right byteString ->
736 case D.fromByteString endpointDecoder byteString of
739 case D.fromByteString endpointDecoder byteString of
737 Left _ ->
740 Left _ ->
738− return (Left Exit.PP_BadEndpointContent)
741+ return $ Left $ Exit.PP_BadEndpointContent url
739
742
740 Right (endpoint, expectedHash) ->
743 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) $
742 \(sha, archive) ->
745 \(sha, archive) ->
743 if expectedHash == Http.shaToChars sha
746 if expectedHash == Http.shaToChars sha
744 then Right <$> File.writePackage (Stuff.package cache pkg vsn) archive
747 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)
746
749
747
750
748endpointDecoder :: D.Decoder e (String, String)
751endpointDecoder :: D.Decoder e (String, String)
builder/src/Reporting/Exit.hs+63−5
@@ -1145,8 +1145,8 @@ toDetailsReport details =
1145 toRegistryProblemReport "PROBLEM LOADING PACKAGE LIST" problem $
1145 toRegistryProblemReport "PROBLEM LOADING PACKAGE LIST" problem $
1146 "I need the list of published packages to figure out if your project has compatible dependencies"
1146 "I need the list of published packages to figure out if your project has compatible dependencies"
1147
1147
1148− DetailsCannotBuildPackage name version problem ->
1148+ DetailsCannotBuildPackage pkg vsn problem ->
1149− error "TODO DetailsCannotBuildPackage" name version problem
1149+ toPackageProblemReport pkg vsn problem
1150
1150
1151
1151
1152
1152
@@ -1155,10 +1155,68 @@ toDetailsReport details =
1155
1155
1156data PackageProblem
1156data PackageProblem
1157 = PP_BadEndpointRequest Http.Error
1157 = PP_BadEndpointRequest Http.Error
1158− | PP_BadEndpointContent
1158+ | PP_BadEndpointContent String
1159 | PP_BadArchiveRequest Http.Error
1159 | PP_BadArchiveRequest Http.Error
1160− | PP_BadArchiveContent
1160+ | PP_BadArchiveContent String
1161− | PP_BadArchiveHash String 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+ ]
1162
1220
1163
1221
1164
1222