on master help sign in
Shuffle different errors around in Reporting.Exit
commit886b167ecdc328771db7e90bd945853e3ff337a6 authorEvan Czaplicki <evancz@users.noreply.github.com> dateTue 16 Apr 2019, 15:01 (8 years ago) parentcae261c
1 file changed+115−51
builder/src/Reporting/Exit.hs+115−51
builder/src/Reporting/Exit.hs+115−51
@@ -11,9 +11,12 @@ module Reporting.Exit
1111 , Install(..)
1212 , installToReport
1313 --
14− , Details(..)
14+ , Solver(..)
15+ --
16+ , Outline(..)
1517 , OutlineProblem(..)
16− , OutlineStructureProblem(..)
18+ --
19+ , Details(..)
1720 , RegistryProblem(..)
1821 , PackageProblem(..)
1922 --
@@ -91,6 +94,8 @@ data DocsProblem
9194
9295data Init
9396 = InitNoSolution [Pkg.Name]
97+ | InitNoOfflineSolution [Pkg.Name]
98+ | InitSolverProblem Solver
9499 | InitAlreadyExists
95100 | InitRegistryProblem RegistryProblem
96101
@@ -109,6 +114,16 @@ initToReport exit =
109114 \ what is going on!"
110115 ]
111116
117+ InitNoOfflineSolution pkgs ->
118+ Help.report "NO OFFLINE SOLUTION" Nothing
119+ (error "TODO InitNoOfflineSolution" pkgs)
120+ (error "TODO InitNoOfflineSolution" pkgs)
121+ -- note about Russia IP addresses?
122+ -- ask if they are on a plane or train
123+
124+ InitSolverProblem solver ->
125+ error "TODO InitSolverProblem" solver
126+
112127 InitAlreadyExists ->
113128 Help.report "EXISTING PROJECT" Nothing
114129 "You already have an elm.json file, so there is nothing for me to initialize!"
@@ -192,7 +207,12 @@ diffToReport diff =
192207data Install
193208 = InstallNoProject
194209 | InstallNoArgs FilePath
195− | InstallNoSolution [Pkg.Name]
210+ | InstallNoOnlineSolution
211+ | InstallNoOfflineSolution
212+ | InstallHadSolverTrouble Solver
213+ | InstallUnknownPackageOnline [Pkg.Name]
214+ | InstallUnknownPackageOffline [Pkg.Name]
215+ | InstallHasBadDetails Details
196216
197217
198218installToReport :: Install -> Help.Report
@@ -200,8 +220,10 @@ installToReport exit =
200220 case exit of
201221 InstallNoProject ->
202222 Help.report "NEW PROJECT?" Nothing
203− (error "TODO InstallNoProject")
204− (error "TODO InstallNoProject details")
223+ "Are you trying to start a new project? Try this command instead:"
224+ [ D.indent 4 $ D.green "elm init"
225+ , D.reflow "It will help you get started!"
226+ ]
205227
206228 InstallNoArgs elmHome ->
207229 Help.report "INSTALL WHAT?" Nothing
@@ -226,35 +248,81 @@ installToReport exit =
226248 ]
227249 ]
228250
229− InstallNoSolution badPackages ->
230− case badPackages of
231− [] ->
232− Help.report "UNSOLVABLE DEPENDENCIES" (Just "elm.json") -- TODO give better advice!
233− "This usually happens if you try to modify dependency constraints by\
234− \ hand. I recommend deleting any dependency you added recently (or all\
235− \ of them if things are bad) and then adding them again with:"
236− [ D.indent 4 $ D.green "elm install"
237− , D.reflow $
238− "And do not be afaid to ask for help on Slack if you get stuck!"
239− ]
251+ InstallNoOnlineSolution ->
252+ Help.report "UNSOLVABLE DEPENDENCIES" (Just "elm.json") -- TODO recommend using solver in `elm reactor`
253+ "This usually happens if you try to modify dependency constraints by\
254+ \ hand. I recommend deleting any dependency you added recently (or all\
255+ \ of them if things are bad) and then adding them again with:"
256+ [ D.indent 4 $ D.green "elm install"
257+ , D.reflow $
258+ "And do not be afaid to ask for help on Slack if you get stuck!"
259+ ]
260+
261+ InstallNoOfflineSolution ->
262+ error "TODO InstallNoOfflineSolution"
263+
264+ InstallHadSolverTrouble solver ->
265+ error "TODO InstallHadSolverTrouble" solver
266+
267+ InstallUnknownPackageOnline suggestions ->
268+ error "TODO InstallUnknownPackageOnline" suggestions
269+
270+ InstallUnknownPackageOffline suggestions ->
271+ error "TODO InstallUnknownPackageOffline" suggestions
272+
273+ InstallHasBadDetails _ ->
274+ error "TODO InstallHasBadDetails"
275+
276+
277+{- TODO detect if library has no 0.19.0 version. Maybe do this on website though?
278+ Help.report "OLD DEPENDENCIES" (Just "elm.json")
279+ ( "The following packages do not work with Elm " ++ V.toChars V.compiler ++ " right now:"
280+ )
281+ [ D.indent 4 $ D.vcat $ map (D.red . D.fromUtf8 . Pkg.toString) badPackages
282+ , D.reflow $
283+ "This may be because it is not upgraded yet. It may be because a\
284+ \ better solution came along, so there was no need to upgrade it.\
285+ \ Etc. Try asking around on Slack to learn more about the topic."
286+ , D.toSimpleNote
287+ "Whatever the case, please be kind to the relevant package authors! Having\
288+ \ friendly interactions with users is great motivation, and conversely, getting\
289+ \ berated by strangers on the internet sucks your soul dry. Furthermore, package\
290+ \ authors are humans with families, friends, jobs, vacations, responsibilities,\
291+ \ goals, etc. They face obstacles outside of their technical work you will never\
292+ \ know about, so please assume the best and try to be patient and supportive!"
293+ ]
294+-}
295+
240296
241− _:_ ->
242− Help.report "OLD DEPENDENCIES" (Just "elm.json")
243− ( "The following packages do not work with Elm " ++ V.toChars V.compiler ++ " right now:"
244− )
245− [ D.indent 4 $ D.vcat $ map (D.red . D.fromUtf8 . Pkg.toString) badPackages
246− , D.reflow $
247− "This may be because it is not upgraded yet. It may be because a\
248− \ better solution came along, so there was no need to upgrade it.\
249− \ Etc. Try asking around on Slack to learn more about the topic."
250− , D.toSimpleNote
251− "Whatever the case, please be kind to the relevant package authors! Having\
252− \ friendly interactions with users is great motivation, and conversely, getting\
253− \ berated by strangers on the internet sucks your soul dry. Furthermore, package\
254− \ authors are humans with families, friends, jobs, vacations, responsibilities,\
255− \ goals, etc. They face obstacles outside of their technical work you will never\
256− \ know about, so please assume the best and try to be patient and supportive!"
257− ]
297+
298+-- SOLVER
299+
300+
301+data Solver
302+ = SolverBadCacheData Pkg.Name V.Version
303+ | SolverBadHttpData Pkg.Name V.Version
304+ | SolverBadHttp Http.Error
305+
306+
307+
308+-- OUTLINE
309+
310+
311+data Outline
312+ = OutlineHasBadStructure (Json.Error OutlineProblem)
313+ | OutlineHasBadSrcDirs FilePath [FilePath]
314+
315+
316+data OutlineProblem
317+ = OP_BadType Utf8.String
318+ | OP_BadPkgName Pkg.BadName
319+ | OP_BadVersion Utf8.String
320+ | OP_BadConstraint C.Error
321+ | OP_BadModuleName Utf8.String
322+ | OP_BadModuleHeaderTooLong Utf8.String
323+ | OP_BadDependencyName Utf8.String
324+ | OP_BadLicense Utf8.String [Utf8.String]
325+ | OP_BadSummaryTooLong
258326
259327
260328
@@ -263,31 +331,17 @@ installToReport exit =
263331
264332data Details
265333 = DetailsCorrupt
334+ | DetailsNoSolution
335+ | DetailsNoOfflineSolution
336+ | DetailsSolverProblem Solver
266337 | DetailsBadElmInPkg C.Constraint
267338 | DetailsBadElmInAppOutline V.Version
268339 | DetailsHandEditedDependencies
269− | DetailsBadOutline OutlineProblem
340+ | DetailsBadOutline Outline
270341 | DetailsCannotGetRegistry RegistryProblem
271342 | DetailsCannotBuildPackage Pkg.Name V.Version PackageProblem
272343
273344
274−data OutlineProblem
275− = BadOutlineStructure (Json.Error OutlineStructureProblem)
276− | BadOutlineSrcDirs FilePath [FilePath]
277−
278−
279−data OutlineStructureProblem
280− = OSP_BadType Utf8.String
281− | OSP_BadPkgName Pkg.BadName
282− | OSP_BadVersion Utf8.String
283− | OSP_BadConstraint C.Error
284− | OSP_BadModuleName Utf8.String
285− | OSP_BadModuleHeaderTooLong Utf8.String
286− | OSP_BadDependencyName Utf8.String
287− | OSP_BadLicense Utf8.String [Utf8.String]
288− | OSP_BadSummaryTooLong
289−
290−
291345data RegistryProblem
292346 = RP_Http Http.Error
293347 | RP_Data
@@ -652,6 +706,16 @@ detailsToReport details =
652706 DetailsCannotBuildPackage name version problem ->
653707 error "TODO DetailsCannotBuildPackage" name version problem
654708
709+ DetailsNoSolution ->
710+ error "TODO DetailsNoSolution"
711+
712+ DetailsNoOfflineSolution ->
713+ error "TODO DetailsNoOfflineSolution"
714+
715+ DetailsSolverProblem _ ->
716+ error "TODO DetailsSolverProblem"
717+
718+
655719
656720makeToReport :: Make -> Help.Report
657721makeToReport make =