on master help sign in
add messages for solver errors
aac806cEvan Czaplicki
builder/src/Deps/Solver.hs+4−3
@@ -311,10 +311,11 @@ getConstraints pkg vsn =
311 back state
311 back state
312
312
313 Online manager ->
313 Online manager ->
314− do result <- Http.get manager (Website.metadata pkg vsn "elm.json") [] id (return . Right)
314+ do let url = Website.metadata pkg vsn "elm.json"
315+ result <- Http.get manager url [] id (return . Right)
315 case result of
316 case result of
316 Left httpProblem ->
317 Left httpProblem ->
317− err (Exit.SolverBadHttp httpProblem)
318+ err (Exit.SolverBadHttp pkg vsn httpProblem)
318
319
319 Right body ->
320 Right body ->
320 case D.fromByteString constraintsDecoder body of
321 case D.fromByteString constraintsDecoder body of
@@ -324,7 +325,7 @@ getConstraints pkg vsn =
324 ok (toNewState cs) cs back
325 ok (toNewState cs) cs back
325
326
326 Left _ ->
327 Left _ ->
327− err (Exit.SolverBadHttpData pkg vsn)
328+ err (Exit.SolverBadHttpData pkg vsn url)
328
329
329
330
330constraintsDecoder :: D.Decoder () Constraints
331constraintsDecoder :: D.Decoder () Constraints
builder/src/Reporting/Exit.hs+42−6
@@ -119,7 +119,7 @@ initToReport exit =
119 ]
119 ]
120
120
121 InitSolverProblem solver ->
121 InitSolverProblem solver ->
122− error "TODO InitSolverProblem" solver
122+ toSolverReport solver
123
123
124 InitAlreadyExists ->
124 InitAlreadyExists ->
125 Help.report "EXISTING PROJECT" Nothing
125 Help.report "EXISTING PROJECT" Nothing
@@ -801,7 +801,7 @@ installToReport exit =
801 error "TODO InstallNoOfflineSolution"
801 error "TODO InstallNoOfflineSolution"
802
802
803 InstallHadSolverTrouble solver ->
803 InstallHadSolverTrouble solver ->
804− error "TODO InstallHadSolverTrouble" solver
804+ toSolverReport solver
805
805
806 InstallUnknownPackageOnline pkg suggestions ->
806 InstallUnknownPackageOnline pkg suggestions ->
807 Help.docReport "UNKNOWN PACKAGE" Nothing
807 Help.docReport "UNKNOWN PACKAGE" Nothing
@@ -873,8 +873,44 @@ installToReport exit =
873
873
874data Solver
874data Solver
875 = SolverBadCacheData Pkg.Name V.Version
875 = SolverBadCacheData Pkg.Name V.Version
876− | SolverBadHttpData Pkg.Name V.Version
876+ | SolverBadHttpData Pkg.Name V.Version String
877− | SolverBadHttp Http.Error
877+ | SolverBadHttp Pkg.Name V.Version Http.Error
878+
879+
880+toSolverReport :: Solver -> Help.Report
881+toSolverReport problem =
882+ case problem of
883+ SolverBadCacheData pkg vsn ->
884+ Help.report "PROBLEM SOLVING PACKAGE CONSTRAINTS" Nothing
885+ (
886+ "I need the elm.json of " ++ Pkg.toChars pkg ++ " " ++ V.toChars vsn ++ " to\
887+ \ help me search for a set of compatible packages. I had it cached locally, but\
888+ \ it looks like the file was corrupted!"
889+ )
890+ [ D.reflow $
891+ "I deleted the cached version, so the next run should download a fresh copy.\
892+ \ Hopefully that will get you unstuck, but it will not resolve the root\
893+ \ problem if a 3rd party tool is modifing cached files for some reason."
894+ ]
895+
896+ SolverBadHttpData pkg vsn url ->
897+ Help.report "PROBLEM SOLVING PACKAGE CONSTRAINTS" Nothing
898+ (
899+ "I need the elm.json of " ++ Pkg.toChars pkg ++ " " ++ V.toChars vsn ++ " to\
900+ \ help me search for a set of compatible packages, but I ran into corrupted\
901+ \ information from:"
902+ )
903+ [ D.indent 4 $ D.dullyellow $ D.fromChars url
904+ , D.reflow $
905+ "Is something weird with your internet connection. We have gotten reports that\
906+ \ schools, businesses, airports, etc. sometimes intercept requests and add things\
907+ \ to the body or change its contents entirely. Could that be the problem?"
908+ ]
909+
910+ SolverBadHttp pkg vsn httpError ->
911+ toHttpErrorReport "PROBLEM SOLVING PACKAGE CONSTRAINTS" httpError $
912+ "I need the elm.json of " ++ Pkg.toChars pkg ++ " " ++ V.toChars vsn
913+ ++ " to help me search for a set of compatible packages"
878
914
879
915
880
916
@@ -1192,8 +1228,8 @@ toDetailsReport details =
1192 ]
1228 ]
1193 ]
1229 ]
1194
1230
1195− DetailsSolverProblem _ ->
1231+ DetailsSolverProblem solver ->
1196− error "TODO DetailsSolverProblem"
1232+ toSolverReport solver
1197
1233
1198 DetailsBadElmInPkg constraint ->
1234 DetailsBadElmInPkg constraint ->
1199 Help.report "ELM VERSION MISMATCH" (Just "elm.json")
1235 Help.report "ELM VERSION MISMATCH" (Just "elm.json")