on master help sign in
add messages for solver errors
commitaac806ca0e811156947aa69860f6ecd07c0f720f authorEvan Czaplicki <evancz@users.noreply.github.com> dateWed 26 Jun 2019, 11:06 (7 years ago) parent78a1ea2
2 files changed+46−9
builder/src/Deps/Solver.hs+4−3 builder/src/Reporting/Exit.hs+42−6
builder/src/Deps/Solver.hs+4−3
@@ -311,10 +311,11 @@ getConstraints pkg vsn =
311311 back state
312312
313313 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)
315316 case result of
316317 Left httpProblem ->
317− err (Exit.SolverBadHttp httpProblem)
318+ err (Exit.SolverBadHttp pkg vsn httpProblem)
318319
319320 Right body ->
320321 case D.fromByteString constraintsDecoder body of
@@ -324,7 +325,7 @@ getConstraints pkg vsn =
324325 ok (toNewState cs) cs back
325326
326327 Left _ ->
327− err (Exit.SolverBadHttpData pkg vsn)
328+ err (Exit.SolverBadHttpData pkg vsn url)
328329
329330
330331constraintsDecoder :: D.Decoder () Constraints
builder/src/Reporting/Exit.hs+42−6
@@ -119,7 +119,7 @@ initToReport exit =
119119 ]
120120
121121 InitSolverProblem solver ->
122− error "TODO InitSolverProblem" solver
122+ toSolverReport solver
123123
124124 InitAlreadyExists ->
125125 Help.report "EXISTING PROJECT" Nothing
@@ -801,7 +801,7 @@ installToReport exit =
801801 error "TODO InstallNoOfflineSolution"
802802
803803 InstallHadSolverTrouble solver ->
804− error "TODO InstallHadSolverTrouble" solver
804+ toSolverReport solver
805805
806806 InstallUnknownPackageOnline pkg suggestions ->
807807 Help.docReport "UNKNOWN PACKAGE" Nothing
@@ -873,8 +873,44 @@ installToReport exit =
873873
874874data Solver
875875 = SolverBadCacheData Pkg.Name V.Version
876− | SolverBadHttpData Pkg.Name V.Version
877− | SolverBadHttp Http.Error
876+ | SolverBadHttpData Pkg.Name V.Version String
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"
878914
879915
880916
@@ -1192,8 +1228,8 @@ toDetailsReport details =
11921228 ]
11931229 ]
11941230
1195− DetailsSolverProblem _ ->
1196− error "TODO DetailsSolverProblem"
1231+ DetailsSolverProblem solver ->
1232+ toSolverReport solver
11971233
11981234 DetailsBadElmInPkg constraint ->
11991235 Help.report "ELM VERSION MISMATCH" (Just "elm.json")