on master help sign in
add error messages for problems loading docs.json
commit075be13fbc999328ddd982bba8075e99fd41cc19 authorEvan Czaplicki <evancz@users.noreply.github.com> dateFri 14 Jun 2019, 12:07 (7 years ago) parent16d3223
2 files changed+49−11
builder/src/Deps/Diff.hs+1−1 builder/src/Reporting/Exit.hs+48−10
builder/src/Deps/Diff.hs+1−1
@@ -380,4 +380,4 @@ getDocs cache manager name version =
380380 return $ Right docs
381381
382382 Left _ ->
383− return $ Left Exit.DP_Data
383+ return $ Left $ Exit.DP_Data url body
builder/src/Reporting/Exit.hs+48−10
@@ -130,7 +130,7 @@ data Diff
130130 | DiffUnpublished
131131 | DiffUnknownPackage Pkg.Name [Pkg.Name]
132132 | DiffUnknownVersion Pkg.Name V.Version [V.Version]
133− | DiffDocsProblem DocsProblem
133+ | DiffDocsProblem V.Version DocsProblem
134134 | DiffMustHaveLatestRegistry RegistryProblem
135135 | DiffBadDetails Details
136136 | DiffBadBuild BuildProblem
@@ -198,8 +198,9 @@ diffToReport diff =
198198 , "Want one of those instead?"
199199 ]
200200
201− DiffDocsProblem problem ->
202− error "TODO DiffDocsProblem" problem
201+ DiffDocsProblem version problem ->
202+ toDocsProblemReport problem $
203+ "I need the docs for " ++ V.toChars version ++ " to compute this diff"
203204
204205 DiffMustHaveLatestRegistry problem ->
205206 toRegistryProblemReport "PROBLEM UPDATING PACKAGE LIST" problem $
@@ -266,8 +267,9 @@ bumpToReport bump =
266267 toRegistryProblemReport "PROBLEM UPDATING PACKAGE LIST" problem $
267268 "I need the latest list of published packages before I can bump any versions"
268269
269− BumpCannotFindDocs name version problem ->
270− error "TODO BumpCannotFindDocs" name version problem
270+ BumpCannotFindDocs _ version problem ->
271+ toDocsProblemReport problem $
272+ "I need the docs for " ++ V.toChars version ++ " to compute the next version number"
271273
272274
273275
@@ -317,7 +319,7 @@ data Publish
317319 | PublishCannotGetTag Http.Error
318320 | PublishCannotGetZip Http.Error
319321 | PublishCannotDecodeZip
320− | PublishCannotGetDocs DocsProblem
322+ | PublishCannotGetDocs V.Version V.Version DocsProblem
321323 | PublishCannotRegister Http.Error
322324 | PublishMissingTag V.Version
323325 | PublishNoGit
@@ -491,8 +493,10 @@ publishToReport publish =
491493 PublishCannotDecodeZip ->
492494 error "TODO PublishCannotDecodeZip"
493495
494− PublishCannotGetDocs docsProblem ->
495− error "TODO PublishCannotGetDocs" docsProblem
496+ PublishCannotGetDocs old new docsProblem ->
497+ toDocsProblemReport docsProblem $
498+ "I need the docs for " ++ V.toChars old ++ " to verify that "
499+ ++ V.toChars new ++ " really does come next"
496500
497501 PublishCannotRegister httpError ->
498502 error "TODO PublishCannotRegister" httpError
@@ -587,10 +591,44 @@ toBadReadmeReport title summary =
587591
588592data DocsProblem
589593 = DP_Http Http.Error
590− | DP_Data
594+ | DP_Data String BS.ByteString
591595 | DP_Cache
592596
593597
598+toDocsProblemReport :: DocsProblem -> String -> Help.Report
599+toDocsProblemReport problem context =
600+ case problem of
601+ DP_Http httpError ->
602+ toHttpErrorReport "PROBLEM FETCHING DOCS" httpError context
603+
604+ DP_Data url body ->
605+ Help.report "PROBLEM FETCHING DOCS" Nothing (context ++ ", so I fetched:")
606+ [ D.indent 4 $ D.dullyellow $ D.fromChars url
607+ , D.reflow $
608+ "I got the data back, but it was not what I was expecting. The response\
609+ \ body contains " ++ show (BS.length body) ++ " bytes. Here is the "
610+ ++ if BS.length body <= 76 then "whole thing:" else "beginning:"
611+ , D.indent 4 $ D.dullyellow $ D.fromChars $
612+ if BS.length body <= 76
613+ then BS_UTF8.toString body
614+ else take 73 (BS_UTF8.toString body) ++ "..."
615+ , D.reflow $
616+ "Does this error keep showing up? Maybe there is something weird with your\
617+ \ internet connection. We have gotten reports that schools, businesses,\
618+ \ airports, etc. sometimes intercept requests and add things to the body\
619+ \ or change its contents entirely. Could that be the problem?"
620+ ]
621+
622+ DP_Cache ->
623+ Help.report "PROBLEM LOADING DOCS" Nothing (context ++ ", but the local copy seems to be corrupted.")
624+ [ D.reflow $
625+ "I deleted the cached version, so the next run should download a fresh copy of\
626+ \ the docs. Hopefully that will get you unstuck, but it will not resolve the root\
627+ \ problem if, for example, a 3rd party editor plugin is modifing cached files\
628+ \ for some reason."
629+ ]
630+
631+
594632
595633-- INSTALL
596634
@@ -793,7 +831,7 @@ toHttpErrorReport title err context =
793831 , D.indent 4 $ D.fromChars reason
794832 , D.reflow $
795833 "This may indicate that there is some problem in the compiler, so please open an\
796− \ issue at https://github.com/elm/compiler/issues listing your operating system\
834+ \ issue at https://github.com/elm/compiler/issues listing your operating system, Elm\
797835 \ version, the command you ran, the terminal output, and any additional information\
798836 \ that might help others reproduce the error."
799837 ]