on master help sign in
add real error messages for two scenarios in `elm install`
783e7b9Evan Czaplicki
builder/src/Reporting/Exit.hs+11−2
@@ -695,7 +695,9 @@ toDocsProblemReport problem context =
695
695
696
696
697data Install
697data Install
698− = InstallNoProject
698+ = InstallNoOutline
699+ | InstallBadOutline Outline
700+ | InstallBadRegistry RegistryProblem
699 | InstallNoArgs FilePath
701 | InstallNoArgs FilePath
700 | InstallNoOnlineSolution
702 | InstallNoOnlineSolution
701 | InstallNoOfflineSolution
703 | InstallNoOfflineSolution
@@ -708,13 +710,20 @@ data Install
708installToReport :: Install -> Help.Report
710installToReport :: Install -> Help.Report
709installToReport exit =
711installToReport exit =
710 case exit of
712 case exit of
711− InstallNoProject ->
713+ InstallNoOutline ->
712 Help.report "NEW PROJECT?" Nothing
714 Help.report "NEW PROJECT?" Nothing
713 "Are you trying to start a new project? Try this command instead:"
715 "Are you trying to start a new project? Try this command instead:"
714 [ D.indent 4 $ D.green "elm init"
716 [ D.indent 4 $ D.green "elm init"
715 , D.reflow "It will help you get started!"
717 , D.reflow "It will help you get started!"
716 ]
718 ]
717
719
720+ InstallBadOutline outline ->
721+ toOutlineReport outline
722+
723+ InstallBadRegistry problem ->
724+ toRegistryProblemReport "PROBLEM LOADING PACKAGE LIST" problem $
725+ "I need the list of published packages to figure out how to install things"
726+
718 InstallNoArgs elmHome ->
727 InstallNoArgs elmHome ->
719 Help.report "INSTALL WHAT?" Nothing
728 Help.report "INSTALL WHAT?" Nothing
720 "I am expecting commands like:"
729 "I am expecting commands like:"
terminal/src/Install.hs+3−20
@@ -40,7 +40,7 @@ run args () =
40 do maybeRoot <- Stuff.findRoot
40 do maybeRoot <- Stuff.findRoot
41 case maybeRoot of
41 case maybeRoot of
42 Nothing ->
42 Nothing ->
43− return (Left Exit.InstallNoProject)
43+ return (Left Exit.InstallNoOutline)
44
44
45 Just root ->
45 Just root ->
46 case args of
46 case args of
@@ -50,8 +50,8 @@ run args () =
50
50
51 Install pkg ->
51 Install pkg ->
52 Task.run $
52 Task.run $
53− do env <- getEnv
53+ do env <- Task.eio Exit.InstallBadRegistry $ Solver.initEnv
54− oldOutline <- getOutline root
54+ oldOutline <- Task.eio Exit.InstallBadOutline $ Outline.read root
55 case oldOutline of
55 case oldOutline of
56 Outline.App outline ->
56 Outline.App outline ->
57 do changes <- makeAppPlan env pkg outline
57 do changes <- makeAppPlan env pkg outline
@@ -63,23 +63,6 @@ run args () =
63
63
64
64
65
65
66−getEnv :: Task Solver.Env
67−getEnv =
68− do eitherEnv <- Task.io Solver.initEnv
69− case eitherEnv of
70− Right env -> return env
71− Left problem -> Task.throw (error "TODO getEnv" problem)
72−
73−
74−getOutline :: FilePath -> Task Outline.Outline
75−getOutline root =
76− do eitherOutline <- Task.io (Outline.read root)
77− case eitherOutline of
78− Right outline -> return outline
79− Left exit -> Task.throw (error "TODO getOutline" exit)
80−
81−
82−
83-- ATTEMPT CHANGES
66-- ATTEMPT CHANGES
84
67
85
68