on master help sign in
Switch Error to Exit in builder/
1063c93Evan Czaplicki
builder/src/Deps/Explorer.hs+3−3
@@ -28,8 +28,8 @@ import Elm.Package (Name, Version)
28import qualified Deps.Get as Get
28import qualified Deps.Get as Get
29import qualified Elm.Project.Json as Project
29import qualified Elm.Project.Json as Project
30import Elm.Project.Constraint (Constraint)
30import Elm.Project.Constraint (Constraint)
31−import qualified Reporting.Error2 as Error
31+import qualified Reporting.Exit as Exit
32−import qualified Reporting.Error.Deps as E
32+import qualified Reporting.Exit.Deps as E
33import qualified Reporting.Task as Task
33import qualified Reporting.Task as Task
34
34
35
35
@@ -73,7 +73,7 @@ getVersions name =
73 return versions
73 return versions
74
74
75 Left _suggestions ->
75 Left _suggestions ->
76− throwError (Error.Deps (E.CorruptVersionCache name))
76+ throwError (Exit.Deps (E.CorruptVersionCache name))
77
77
78
78
79
79
builder/src/Deps/Get.hs+4−4
@@ -28,8 +28,8 @@ import qualified Deps.Website as Website
28import qualified Elm.Project.Json as Project
28import qualified Elm.Project.Json as Project
29import qualified Elm.Utils as Utils
29import qualified Elm.Utils as Utils
30import qualified File.IO as IO
30import qualified File.IO as IO
31−import qualified Reporting.Error2 as Error
31+import qualified Reporting.Exit as Exit
32−import qualified Reporting.Error.Assets as E
32+import qualified Reporting.Exit.Assets as E
33import qualified Reporting.Progress as Progress
33import qualified Reporting.Progress as Progress
34import qualified Reporting.Task as Task
34import qualified Reporting.Task as Task
35import qualified Json.Decode as Decode
35import qualified Json.Decode as Decode
@@ -129,7 +129,7 @@ info name version =
129
129
130 Left _ ->
130 Left _ ->
131 do IO.remove elmJson
131 do IO.remove elmJson
132− Task.throw $ Error.Assets $ E.CorruptElmJson name version
132+ Task.throw $ Exit.Assets $ E.CorruptElmJson name version
133
133
134
134
135
135
@@ -157,7 +157,7 @@ docs name version =
157
157
158 Left _ ->
158 Left _ ->
159 do IO.remove docsJson
159 do IO.remove docsJson
160− Task.throw $ Error.Assets $ E.CorruptDocumentation name version
160+ Task.throw $ Exit.Assets $ E.CorruptDocumentation name version
161
161
162
162
163errorToDocs :: Docs.Error -> [P.Doc]
163errorToDocs :: Docs.Error -> [P.Doc]
builder/src/Deps/Verify.hs+5−5
@@ -36,8 +36,8 @@ import qualified File.Compile as Compile
36import qualified File.Crawl as Crawl
36import qualified File.Crawl as Crawl
37import qualified File.IO as IO
37import qualified File.IO as IO
38import qualified File.Plan as Plan
38import qualified File.Plan as Plan
39−import qualified Reporting.Error2 as Error
39+import qualified Reporting.Exit as Exit
40−import qualified Reporting.Error.Deps as E
40+import qualified Reporting.Exit.Deps as E
41import qualified Reporting.Progress as Progress
41import qualified Reporting.Progress as Progress
42import qualified Reporting.Task as Task
42import qualified Reporting.Task as Task
43import qualified Stuff.Paths as Paths
43import qualified Stuff.Paths as Paths
@@ -55,9 +55,9 @@ verify root project =
55 return (solution, summary)
55 return (solution, summary)
56
56
57
57
58−throw :: E.Error -> Task.Task a
58+throw :: E.Exit -> Task.Task a
59−throw err =
59+throw exit =
60− Task.throw (Error.Deps err)
60+ Task.throw (Exit.Deps exit)
61
61
62
62
63
63
builder/src/Deps/Website.hs+4−4
@@ -35,7 +35,7 @@ import Elm.Package (Name, Version)
35import qualified Elm.Package as Pkg
35import qualified Elm.Package as Pkg
36import qualified Json.Decode as D
36import qualified Json.Decode as D
37
37
38−import qualified Reporting.Error.Http as E
38+import qualified Reporting.Exit.Http as E
39import qualified Reporting.Progress as Progress
39import qualified Reporting.Progress as Progress
40import qualified Reporting.Task as Task
40import qualified Reporting.Task as Task
41import qualified Reporting.Task.Http as Http
41import qualified Reporting.Task.Http as Http
@@ -188,7 +188,7 @@ endpointDecoder =
188-- DOWNLOAD ZIP ARCHIVE
188-- DOWNLOAD ZIP ARCHIVE
189
189
190
190
191−downloadArchive :: FilePath -> Name -> Version -> String -> Client.Response Client.BodyReader -> IO (Either E.Error ())
191+downloadArchive :: FilePath -> Name -> Version -> String -> Client.Response Client.BodyReader -> IO (Either E.Exit ())
192downloadArchive cache name version expectedHash response =
192downloadArchive cache name version expectedHash response =
193 do result <- readArchive (Client.responseBody response) initialArchiveState
193 do result <- readArchive (Client.responseBody response) initialArchiveState
194 case result of
194 case result of
@@ -222,7 +222,7 @@ initialArchiveState =
222type Sha = SHA.Digest SHA.SHA1State
222type Sha = SHA.Digest SHA.SHA1State
223
223
224
224
225−readArchive :: Client.BodyReader -> ArchiveState -> IO (Either E.Error (Sha, Zip.Archive))
225+readArchive :: Client.BodyReader -> ArchiveState -> IO (Either E.Exit (Sha, Zip.Archive))
226readArchive body (AS len sha zip) =
226readArchive body (AS len sha zip) =
227 case zip of
227 case zip of
228 Binary.Fail _ _ _ ->
228 Binary.Fail _ _ _ ->
@@ -303,7 +303,7 @@ githubDownload name version dir =
303 Client.withResponse request manager (githubDownloadHelp dir)
303 Client.withResponse request manager (githubDownloadHelp dir)
304
304
305
305
306−githubDownloadHelp :: FilePath -> Client.Response Client.BodyReader -> IO (Either E.Error Sha)
306+githubDownloadHelp :: FilePath -> Client.Response Client.BodyReader -> IO (Either E.Exit Sha)
307githubDownloadHelp targetDir response =
307githubDownloadHelp targetDir response =
308 do result <- readArchive (Client.responseBody response) initialArchiveState
308 do result <- readArchive (Client.responseBody response) initialArchiveState
309 case result of
309 case result of
builder/src/Elm/Bump.hs+5−5
@@ -17,9 +17,9 @@ import qualified Elm.Package as Pkg
17import qualified Elm.Project as Project
17import qualified Elm.Project as Project
18import qualified Elm.Project.Json as Project
18import qualified Elm.Project.Json as Project
19import qualified Elm.Project.Summary as Summary
19import qualified Elm.Project.Summary as Summary
20−import qualified Reporting.Error2 as Error
20+import qualified Reporting.Exit as Exit
21−import qualified Reporting.Error.Bump as E
21+import qualified Reporting.Exit.Bump as E
22−import qualified Reporting.Error.Help as Help
22+import qualified Reporting.Exit.Help as Help
23import qualified Reporting.Progress.Terminal as Terminal
23import qualified Reporting.Progress.Terminal as Terminal
24import qualified Reporting.Task as Task
24import qualified Reporting.Task as Task
25
25
@@ -32,7 +32,7 @@ bump :: Summary.Summary -> Task.Task ()
32bump summary@(Summary.Summary root project _ _ _) =
32bump summary@(Summary.Summary root project _ _ _) =
33 case project of
33 case project of
34 Project.App _ ->
34 Project.App _ ->
35− Task.throw (Error.Bump E.Application)
35+ Task.throw (Exit.Bump E.Application)
36
36
37 Project.Pkg info@(Project.PkgInfo name _ _ version _ _ _ _) ->
37 Project.Pkg info@(Project.PkgInfo name _ _ version _ _ _ _) ->
38 do pkgs <- Get.all Get.RequireLatest
38 do pkgs <- Get.all Get.RequireLatest
@@ -48,7 +48,7 @@ bump summary@(Summary.Summary root project _ _ _) =
48 if elem version bumpableVersions then
48 if elem version bumpableVersions then
49 suggestVersion summary info
49 suggestVersion summary info
50 else
50 else
51− Task.throw $ Error.Bump $ E.Unbumpable version $
51+ Task.throw $ Exit.Bump $ E.Unbumpable version $
52 map head (List.group (List.sort bumpableVersions))
52 map head (List.group (List.sort bumpableVersions))
53
53
54
54
builder/src/Elm/Diff.hs+6−6
@@ -25,9 +25,9 @@ import qualified Elm.Package as Pkg
25import qualified Elm.Project as Project
25import qualified Elm.Project as Project
26import qualified Elm.Project.Json as Project
26import qualified Elm.Project.Json as Project
27import qualified Elm.Project.Summary as Summary
27import qualified Elm.Project.Summary as Summary
28−import qualified Reporting.Error2 as Error
28+import qualified Reporting.Exit as Exit
29−import qualified Reporting.Error.Diff as E
29+import qualified Reporting.Exit.Diff as E
30−import qualified Reporting.Error.Help as Help
30+import qualified Reporting.Exit.Help as Help
31import qualified Reporting.Task as Task
31import qualified Reporting.Task as Task
32
32
33
33
@@ -75,9 +75,9 @@ diff args =
75 writeDoc (toDoc (Diff.diff oldDocs newDocs))
75 writeDoc (toDoc (Diff.diff oldDocs newDocs))
76
76
77
77
78−throw :: E.Error -> Task.Task a
78+throw :: E.Exit -> Task.Task a
79−throw err =
79+throw exit =
80− Task.throw $ Error.Diff err
80+ Task.throw $ Exit.Diff exit
81
81
82
82
83
83
builder/src/Elm/Install.hs+3−3
@@ -24,7 +24,7 @@ import Elm.Project.Constraint (Constraint)
24import qualified Elm.Project.Constraint as Con
24import qualified Elm.Project.Constraint as Con
25import qualified Elm.Project.Json as Project
25import qualified Elm.Project.Json as Project
26import qualified Elm.Project.Root as Root
26import qualified Elm.Project.Root as Root
27−import qualified Reporting.Error2 as Error
27+import qualified Reporting.Exit as Exit
28import qualified Reporting.Task as Task
28import qualified Reporting.Task as Task
29
29
30
30
@@ -146,7 +146,7 @@ addToApp pkg info@(Project.AppInfo _ _ deps tests trans) =
146
146
147 Nothing ->
147 Nothing ->
148 do badNames <- filterM isBadElm (pkg : Map.keys old)
148 do badNames <- filterM isBadElm (pkg : Map.keys old)
149− lift $ Task.throw (Error.NoSolution badNames)
149+ lift $ Task.throw (Exit.NoSolution badNames)
150
150
151
151
152addToAppHelp :: Name -> Project.AppInfo -> Solver.Solver (Map Name Version)
152addToAppHelp :: Name -> Project.AppInfo -> Solver.Solver (Map Name Version)
@@ -186,7 +186,7 @@ addToPkg pkg info@(Project.PkgInfo _ _ _ _ _ deps tests _) =
186 Nothing ->
186 Nothing ->
187 do let pkgs = Map.keys deps ++ Map.keys tests
187 do let pkgs = Map.keys deps ++ Map.keys tests
188 badNames <- filterM isBadElm (pkg : pkgs)
188 badNames <- filterM isBadElm (pkg : pkgs)
189− lift $ Task.throw (Error.NoSolution badNames)
189+ lift $ Task.throw (Exit.NoSolution badNames)
190
190
191
191
192addToPkgHelp :: Name -> Project.PkgInfo -> Solver.Solver (Map Name Constraint)
192addToPkgHelp :: Name -> Project.PkgInfo -> Solver.Solver (Map Name Constraint)
builder/src/Elm/Project/Json.hs+3−3
@@ -41,8 +41,8 @@ import qualified Elm.Project.Constraint as Con
41import qualified Elm.Project.Licenses as Licenses
41import qualified Elm.Project.Licenses as Licenses
42import qualified Json.Decode as D
42import qualified Json.Decode as D
43import qualified Json.Encode as E
43import qualified Json.Encode as E
44−import qualified Reporting.Error2 as Error
44+import qualified Reporting.Exit as Exit
45−import qualified Reporting.Error.Assets as E
45+import qualified Reporting.Exit.Assets as E
46import qualified Reporting.Task as Task
46import qualified Reporting.Task as Task
47
47
48
48
@@ -268,7 +268,7 @@ read path =
268
268
269throwBadJson :: E.ElmJsonProblem -> Task.Task a
269throwBadJson :: E.ElmJsonProblem -> Task.Task a
270throwBadJson problem =
270throwBadJson problem =
271− Task.throw (Error.Assets (E.BadElmJson problem))
271+ Task.throw (Exit.Assets (E.BadElmJson problem))
272
272
273
273
274checkOverlap :: String -> String -> Map Name a -> Map Name a -> Task.Task ()
274checkOverlap :: String -> String -> Map Name a -> Map Name a -> Task.Task ()
builder/src/Elm/Project/Root.hs+2−3
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
1{-# LANGUAGE OverloadedStrings #-}
3module Elm.Project.Root
2module Elm.Project.Root
4 ( get
3 ( get
@@ -20,7 +19,7 @@ import Elm.Project.Json (Project(..), PkgInfo(..))
20import Elm.Project.Summary (Summary)
19import Elm.Project.Summary (Summary)
21import qualified Elm.PerUserCache as PerUserCache
20import qualified Elm.PerUserCache as PerUserCache
22import qualified File.IO as IO
21import qualified File.IO as IO
23−import qualified Reporting.Error2 as Error
22+import qualified Reporting.Exit as Exit
24import qualified Reporting.Task as Task
23import qualified Reporting.Task as Task
25import qualified Stuff.Verify as Verify
24import qualified Stuff.Verify as Verify
26import qualified Json.Encode as Encode
25import qualified Json.Encode as Encode
@@ -55,7 +54,7 @@ moveToRoot =
55 return root
54 return root
56
55
57 Nothing ->
56 Nothing ->
58− Task.throw Error.NoElmJson
57+ Task.throw Exit.NoElmJson
59
58
60
59
61
60
builder/src/Elm/Publish.hs+9−9
@@ -22,8 +22,8 @@ import qualified Elm.Package as Pkg
22import qualified Elm.Project as Project
22import qualified Elm.Project as Project
23import qualified Elm.Project.Json as Project
23import qualified Elm.Project.Json as Project
24import qualified Elm.Project.Summary as Summary
24import qualified Elm.Project.Summary as Summary
25−import qualified Reporting.Error2 as Error
25+import qualified Reporting.Exit as Exit
26−import qualified Reporting.Error.Publish as E
26+import qualified Reporting.Exit.Publish as E
27import qualified Reporting.Progress as Progress
27import qualified Reporting.Progress as Progress
28import qualified Reporting.Task as Task
28import qualified Reporting.Task as Task
29import qualified Stuff.Paths as Path
29import qualified Stuff.Paths as Path
@@ -62,9 +62,9 @@ publish summary@(Summary.Summary root project _ _ _) =
62 Task.report Progress.PublishEnd
62 Task.report Progress.PublishEnd
63
63
64
64
65−throw :: E.Error -> Task.Task a
65+throw :: E.Exit -> Task.Task a
66−throw err =
66+throw exit =
67− Task.throw (Error.Publish err)
67+ Task.throw (Exit.Publish exit)
68
68
69
69
70
70
@@ -191,9 +191,9 @@ phase :: Progress.PublishPhase -> Task.Task a -> Task.Task a
191phase publishPhase task =
191phase publishPhase task =
192 do Task.report $ Progress.PublishProgress publishPhase Nothing
192 do Task.report $ Progress.PublishProgress publishPhase Nothing
193
193
194− result <- task `catchError` \err ->
194+ result <- task `catchError` \exit ->
195 do Task.report $ Progress.PublishProgress publishPhase (Just Progress.Bad)
195 do Task.report $ Progress.PublishProgress publishPhase (Just Progress.Bad)
196− Task.throw err
196+ Task.throw exit
197
197
198 Task.report $ Progress.PublishProgress publishPhase (Just Progress.Good)
198 Task.report $ Progress.PublishProgress publishPhase (Just Progress.Good)
199
199
@@ -225,9 +225,9 @@ verifyVersion name version docs maybePublishedVersions =
225 do (old, magnitude) <- verifyBump name version docs publishedVersions
225 do (old, magnitude) <- verifyBump name version docs publishedVersions
226 reportBumpPhase (Progress.GoodBump old magnitude)
226 reportBumpPhase (Progress.GoodBump old magnitude)
227
227
228− `catchError` \err ->
228+ `catchError` \exit ->
229 do reportBumpPhase Progress.BadBump
229 do reportBumpPhase Progress.BadBump
230− Task.throw err
230+ Task.throw exit
231
231
232
232
233verifyBump :: Pkg.Name -> Pkg.Version -> Docs.Documentation -> [Pkg.Version] -> Task.Task (Pkg.Version, Diff.Magnitude)
233verifyBump :: Pkg.Name -> Pkg.Version -> Docs.Documentation -> [Pkg.Version] -> Task.Task (Pkg.Version, Diff.Magnitude)
builder/src/File/Args.hs+2−2
@@ -11,7 +11,7 @@ import Data.List.NonEmpty (NonEmpty((:|)))
11import qualified Elm.Compiler.Module as Module
11import qualified Elm.Compiler.Module as Module
12import qualified Elm.Project.Json as Project
12import qualified Elm.Project.Json as Project
13import qualified Elm.Project.Summary as Summary
13import qualified Elm.Project.Summary as Summary
14−import qualified Reporting.Error2 as Error
14+import qualified Reporting.Exit as Exit
15import qualified Reporting.Task as Task
15import qualified Reporting.Task as Task
16
16
17
17
@@ -37,4 +37,4 @@ fromSummary (Summary.Summary _ project _ _ _) =
37 return $ Pkg (Project.getExposed info)
37 return $ Pkg (Project.getExposed info)
38
38
39 Project.App _ ->
39 Project.App _ ->
40− Task.throw Error.CannotMakeNothing
40+ Task.throw Exit.CannotMakeNothing
builder/src/File/Crawl.hs+5−5
@@ -29,8 +29,8 @@ import qualified File.Args as Args
29import qualified File.Find as Find
29import qualified File.Find as Find
30import qualified File.Header as Header
30import qualified File.Header as Header
31import qualified File.IO as IO
31import qualified File.IO as IO
32−import qualified Reporting.Error2 as Error
32+import qualified Reporting.Exit as Exit
33−import qualified Reporting.Error.Crawl as E
33+import qualified Reporting.Exit.Crawl as E
34import qualified Reporting.Task as Task
34import qualified Reporting.Task as Task
35
35
36
36
@@ -121,7 +121,7 @@ depthFirstSearch summary unvisited startGraph =
121 return $ Graph args locals kernels foreigns ()
121 return $ Graph args locals kernels foreigns ()
122
122
123 problem : otherProblems ->
123 problem : otherProblems ->
124− Task.throw (Error.Crawl (E.DependencyProblems problem otherProblems))
124+ Task.throw (Exit.Crawl (E.DependencyProblems problem otherProblems))
125
125
126
126
127
127
@@ -147,7 +147,7 @@ checkComponent scc =
147 return ()
147 return ()
148
148
149 Graph.CyclicSCC names ->
149 Graph.CyclicSCC names ->
150− Task.throw (Error.Cycle names)
150+ Task.throw (Exit.Cycle names)
151
151
152
152
153
153
@@ -270,7 +270,7 @@ readKContent importDict path =
270 return content
270 return content
271
271
272 Left _ ->
272 Left _ ->
273− Task.throw (Error.Crawl (E.BadKernelHeader path))
273+ Task.throw (Exit.Crawl (E.BadKernelHeader path))
274
274
275
275
276
276
builder/src/File/Find.hs+1−1
@@ -18,7 +18,7 @@ import qualified Elm.Package as Pkg
18
18
19import qualified Elm.Project.Json as Project
19import qualified Elm.Project.Json as Project
20import qualified Elm.Project.Summary as Summary
20import qualified Elm.Project.Summary as Summary
21−import qualified Reporting.Error.Crawl as E
21+import qualified Reporting.Exit.Crawl as E
22import qualified Reporting.Task as Task
22import qualified Reporting.Task as Task
23
23
24
24
builder/src/File/Header.hs+9−9
@@ -25,8 +25,8 @@ import qualified Elm.Project.Json as Project
25import Elm.Project.Json (Project)
25import Elm.Project.Json (Project)
26import Elm.Project.Summary (Summary(..))
26import Elm.Project.Summary (Summary(..))
27import qualified File.IO as IO
27import qualified File.IO as IO
28−import qualified Reporting.Error2 as Error
28+import qualified Reporting.Exit as Exit
29−import qualified Reporting.Error.Crawl as E
29+import qualified Reporting.Exit.Crawl as E
30import qualified Reporting.Task as Task
30import qualified Reporting.Task as Task
31
31
32
32
@@ -43,7 +43,7 @@ data Info =
43 }
43 }
44
44
45
45
46−atRoot :: Task.Task_ E.Problem a -> Task.Task_ E.Error a
46+atRoot :: Task.Task_ E.Problem a -> Task.Task_ E.Exit a
47atRoot task =
47atRoot task =
48 Task.mapError (\problem -> E.DependencyProblems problem []) task
48 Task.mapError (\problem -> E.DependencyProblems problem []) task
49
49
@@ -78,12 +78,12 @@ checkName path expectedName maybeName =
78
78
79readOneFile :: Summary -> FilePath -> Task.Task (Maybe Module.Raw, Info)
79readOneFile :: Summary -> FilePath -> Task.Task (Maybe Module.Raw, Info)
80readOneFile summary path =
80readOneFile summary path =
81− Task.mapError Error.Crawl $
81+ Task.mapError Exit.Crawl $
82 do (time, source) <- readOneHelp path
82 do (time, source) <- readOneHelp path
83 atRoot $ parse (_project summary) path time source
83 atRoot $ parse (_project summary) path time source
84
84
85
85
86−readOneHelp :: FilePath -> Task.Task_ E.Error (Time.UTCTime, BS.ByteString)
86+readOneHelp :: FilePath -> Task.Task_ E.Exit (Time.UTCTime, BS.ByteString)
87readOneHelp path =
87readOneHelp path =
88 do exists <- IO.exists path
88 do exists <- IO.exists path
89 if exists
89 if exists
@@ -97,7 +97,7 @@ readOneHelp path =
97
97
98readManyFiles :: Summary -> NonEmpty FilePath -> Task.Task (NonEmpty (Module.Raw, Info))
98readManyFiles :: Summary -> NonEmpty FilePath -> Task.Task (NonEmpty (Module.Raw, Info))
99readManyFiles summary files =
99readManyFiles summary files =
100− Task.mapError Error.Crawl $
100+ Task.mapError Exit.Crawl $
101 do infos <- traverse (readManyFilesHelp summary) files
101 do infos <- traverse (readManyFilesHelp summary) files
102 let insert (name, info) dict = Map.insertWith (<>) name (info :| []) dict
102 let insert (name, info) dict = Map.insertWith (<>) name (info :| []) dict
103 let nameTable = foldr insert Map.empty infos
103 let nameTable = foldr insert Map.empty infos
@@ -105,7 +105,7 @@ readManyFiles summary files =
105 return infos
105 return infos
106
106
107
107
108−readManyFilesHelp :: Summary -> FilePath -> Task.Task_ E.Error (Module.Raw, Info)
108+readManyFilesHelp :: Summary -> FilePath -> Task.Task_ E.Exit (Module.Raw, Info)
109readManyFilesHelp summary path =
109readManyFilesHelp summary path =
110 do (time, source) <- readOneHelp path
110 do (time, source) <- readOneHelp path
111 (maybeName, info) <- atRoot $ parse (_project summary) path time source
111 (maybeName, info) <- atRoot $ parse (_project summary) path time source
@@ -117,7 +117,7 @@ readManyFilesHelp summary path =
117 return (name, info)
117 return (name, info)
118
118
119
119
120−detectDuplicateNames :: Module.Raw -> NonEmpty Info -> Task.Task_ E.Error ()
120+detectDuplicateNames :: Module.Raw -> NonEmpty Info -> Task.Task_ E.Exit ()
121detectDuplicateNames name (info :| otherInfos) =
121detectDuplicateNames name (info :| otherInfos) =
122 case otherInfos of
122 case otherInfos of
123 [] ->
123 [] ->
@@ -134,7 +134,7 @@ detectDuplicateNames name (info :| otherInfos) =
134
134
135readSource :: Project -> BS.ByteString -> Task.Task (Maybe Module.Raw, Info)
135readSource :: Project -> BS.ByteString -> Task.Task (Maybe Module.Raw, Info)
136readSource project source =
136readSource project source =
137− Task.mapError Error.Crawl $
137+ Task.mapError Exit.Crawl $
138 atRoot $ parse project "elm" fakeTime source
138 atRoot $ parse project "elm" fakeTime source
139
139
140
140
builder/src/File/IO.hs+3−3
@@ -30,8 +30,8 @@ import qualified System.FilePath as FP
30import qualified System.IO as IO
30import qualified System.IO as IO
31import System.IO.Error (ioeGetErrorType, annotateIOError, modifyIOError)
31import System.IO.Error (ioeGetErrorType, annotateIOError, modifyIOError)
32
32
33−import qualified Reporting.Error2 as Error
33+import qualified Reporting.Exit as Exit
34−import qualified Reporting.Error.Assets as E
34+import qualified Reporting.Exit.Assets as E
35import qualified Reporting.Task as Task
35import qualified Reporting.Task as Task
36
36
37
37
@@ -64,7 +64,7 @@ readBinary path =
64
64
65throwCorruptBinary :: FilePath -> Task.Task a
65throwCorruptBinary :: FilePath -> Task.Task a
66throwCorruptBinary filePath =
66throwCorruptBinary filePath =
67− Task.throw (Error.Assets (E.CorruptBinary filePath))
67+ Task.throw (Exit.Assets (E.CorruptBinary filePath))
68
68
69
69
70
70
builder/src/Reporting/Error2.hs → builder/src/Reporting/Exit.hsrenamed+38−30
@@ -1,45 +1,48 @@
1−{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
1{-# LANGUAGE OverloadedStrings #-}
3−module Reporting.Error2
2+module Reporting.Exit
4− ( Error(..)
3+ ( Exit(..)
5 , toString
4 , toString
6 , toStderr
5 , toStderr
6+ , toJson
7 )
7 )
8 where
8 where
9
9
10
10
11+import qualified Data.ByteString.Builder as B
12+import System.IO (stderr)
11import qualified Text.PrettyPrint.ANSI.Leijen as P
13import qualified Text.PrettyPrint.ANSI.Leijen as P
12
14
13import qualified Elm.Compiler as Compiler
15import qualified Elm.Compiler as Compiler
14import qualified Elm.Compiler.Module as Module
16import qualified Elm.Compiler.Module as Module
15import qualified Elm.Package as Pkg
17import qualified Elm.Package as Pkg
16import qualified Elm.Utils as Utils
18import qualified Elm.Utils as Utils
19+import qualified Json.Encode as Encode
17−import qualified Reporting.Error.Assets as Asset
20+import qualified Reporting.Exit.Assets as Asset
18−import qualified Reporting.Error.Bump as Bump
21+import qualified Reporting.Exit.Bump as Bump
19−import qualified Reporting.Error.Compile as Compile
22+import qualified Reporting.Exit.Compile as Compile
20−import qualified Reporting.Error.Crawl as Crawl
23+import qualified Reporting.Exit.Crawl as Crawl
21−import qualified Reporting.Error.Deps as Deps
24+import qualified Reporting.Exit.Deps as Deps
22−import qualified Reporting.Error.Diff as Diff
25+import qualified Reporting.Exit.Diff as Diff
23−import qualified Reporting.Error.Help as Help
26+import qualified Reporting.Exit.Help as Help
24−import qualified Reporting.Error.Http as Http
27+import qualified Reporting.Exit.Http as Http
25−import qualified Reporting.Error.Publish as Publish
28+import qualified Reporting.Exit.Publish as Publish
26
29
27
30
28
31
29-- ALL POSSIBLE ERRORS
32-- ALL POSSIBLE ERRORS
30
33
31
34
32−data Error
35+data Exit
33 = NoElmJson
36 = NoElmJson
34− | Assets Asset.Error
37+ | Assets Asset.Exit
35− | Bump Bump.Error
38+ | Bump Bump.Exit
36− | Compile Compile.Error [Compile.Error]
39+ | Compile Compile.Exit [Compile.Exit]
37− | Crawl Crawl.Error
40+ | Crawl Crawl.Exit
38 | Cycle [Module.Raw] -- TODO write docs to help with this scenario
41 | Cycle [Module.Raw] -- TODO write docs to help with this scenario
39− | Deps Deps.Error
42+ | Deps Deps.Exit
40− | Diff Diff.Error
43+ | Diff Diff.Exit
41− | Publish Publish.Error
44+ | Publish Publish.Exit
42− | BadHttp String Http.Error
45+ | BadHttp String Http.Exit
43
46
44 -- install
47 -- install
45 | NoSolution [Pkg.Name]
48 | NoSolution [Pkg.Name]
@@ -50,19 +53,24 @@ data Error
50-- RENDERERS
53-- RENDERERS
51
54
52
55
53−toString :: Error -> String
56+toString :: Exit -> String
54−toString err =
57+toString exit =
55− Help.toString (Help.reportToDoc (toReport err))
58+ Help.toString (Help.reportToDoc (toReport exit))
56
59
57
60
58−toStderr :: Error -> IO ()
61+toStderr :: Exit -> IO ()
59−toStderr err =
62+toStderr exit =
60− Help.toStderr (Help.reportToDoc (toReport err))
63+ Help.toStderr (Help.reportToDoc (toReport exit))
61
64
62
65
66+toJson :: Exit -> IO ()
67+toJson exit =
68+ B.hPutBuilder stderr $ Encode.encodeUgly $ Help.reportToJson (toReport exit)
69+
70+
63−toReport :: Error -> Help.Report
71+toReport :: Exit -> Help.Report
64−toReport err =
72+toReport exit =
65− case err of
73+ case exit of
66 NoElmJson ->
74 NoElmJson ->
67 Help.report "WELCOME" Nothing
75 Help.report "WELCOME" Nothing
68 "It looks like you are trying to start a new Elm project. Very exciting! :D"
76 "It looks like you are trying to start a new Elm project. Very exciting! :D"
builder/src/Reporting/Error/Assets.hs → builder/src/Reporting/Exit/Assets.hsrenamed+8−9
@@ -1,7 +1,6 @@
1−{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
1{-# LANGUAGE OverloadedStrings #-}
3−module Reporting.Error.Assets
2+module Reporting.Exit.Assets
4− ( Error(..)
3+ ( Exit(..)
5 , ElmJsonProblem(..)
4 , ElmJsonProblem(..)
6 , toReport
5 , toReport
7 , BadElmJsonContent(..)
6 , BadElmJsonContent(..)
@@ -15,14 +14,14 @@ import qualified Data.Text as Text
15import qualified Text.PrettyPrint.ANSI.Leijen as P
14import qualified Text.PrettyPrint.ANSI.Leijen as P
16
15
17import qualified Elm.Package as Pkg
16import qualified Elm.Package as Pkg
18−import qualified Reporting.Error.Help as Help
17+import qualified Reporting.Exit.Help as Help
19
18
20
19
21
20
22−-- ERRORS
21+-- EXITS
23
22
24
23
25−data Error
24+data Exit
26 = BadElmJson ElmJsonProblem
25 = BadElmJson ElmJsonProblem
27 | CorruptElmJson Pkg.Name Pkg.Version
26 | CorruptElmJson Pkg.Name Pkg.Version
28 | CorruptDocumentation Pkg.Name Pkg.Version
27 | CorruptDocumentation Pkg.Name Pkg.Version
@@ -43,9 +42,9 @@ data ElmJsonProblem
43-- TO REPORT
42-- TO REPORT
44
43
45
44
46−toReport :: Error -> Help.Report
45+toReport :: Exit -> Help.Report
47−toReport err =
46+toReport exit =
48− case err of
47+ case exit of
49 CorruptElmJson pkg vsn ->
48 CorruptElmJson pkg vsn ->
50 corruptJsonToReport "elm.json" pkg vsn
49 corruptJsonToReport "elm.json" pkg vsn
51
50
builder/src/Reporting/Error/Bump.hs → builder/src/Reporting/Exit/Bump.hsrenamed+8−9
@@ -1,7 +1,6 @@
1−{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
1{-# LANGUAGE OverloadedStrings #-}
3−module Reporting.Error.Bump
2+module Reporting.Exit.Bump
4− ( Error(..)
3+ ( Exit(..)
5 , toReport
4 , toReport
6 )
5 )
7 where
6 where
@@ -11,14 +10,14 @@ import Data.Monoid ((<>))
11import qualified Text.PrettyPrint.ANSI.Leijen as P
10import qualified Text.PrettyPrint.ANSI.Leijen as P
12
11
13import qualified Elm.Package as Pkg
12import qualified Elm.Package as Pkg
14−import qualified Reporting.Error.Help as Help
13+import qualified Reporting.Exit.Help as Help
15
14
16
15
17
16
18−-- ERRORS
17+-- EXITS
19
18
20
19
21−data Error
20+data Exit
22 = Application
21 = Application
23 | Unbumpable Pkg.Version [Pkg.Version]
22 | Unbumpable Pkg.Version [Pkg.Version]
24
23
@@ -27,9 +26,9 @@ data Error
27-- TO REPORT
26-- TO REPORT
28
27
29
28
30−toReport :: Error -> Help.Report
29+toReport :: Exit -> Help.Report
31−toReport err =
30+toReport exit =
32− case err of
31+ case exit of
33 Application ->
32 Application ->
34 Help.report "UNBUMPABLE" (Just "elm.json")
33 Help.report "UNBUMPABLE" (Just "elm.json")
35 "Your elm.json says this is an application. That means it cannot be published\
34 "Your elm.json says this is an application. That means it cannot be published\
builder/src/Reporting/Error/Compile.hs → builder/src/Reporting/Exit/Compile.hsrenamed+15−15
@@ -1,7 +1,7 @@
1{-# OPTIONS_GHC -Wall #-}
1{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
2{-# LANGUAGE OverloadedStrings #-}
3−module Reporting.Error.Compile
3+module Reporting.Exit.Compile
4− ( Error(..)
4+ ( Exit(..)
5 , toDoc
5 , toDoc
6 )
6 )
7 where
7 where
@@ -18,11 +18,11 @@ import qualified Elm.Compiler.Module as Module
18
18
19
19
20
20
21−-- ERRORS
21+-- EXITS
22
22
23
23
24−data Error =
24+data Exit =
25− Error
25+ Exit
26 { _name :: Module.Raw
26 { _name :: Module.Raw
27 , _path :: FilePath
27 , _path :: FilePath
28 , _time :: Time.UTCTime
28 , _time :: Time.UTCTime
@@ -35,25 +35,25 @@ data Error =
35-- TO DOC
35-- TO DOC
36
36
37
37
38−toDoc :: Error -> [Error] -> P.Doc
38+toDoc :: Exit -> [Exit] -> P.Doc
39toDoc e es =
39toDoc e es =
40 case NonEmpty.sortWith _time (e :| es) of
40 case NonEmpty.sortWith _time (e :| es) of
41− err :| errors ->
41+ exit :| exits ->
42− P.vcat (toDocHelp err errors)
42+ P.vcat (toDocHelp exit exits)
43
43
44
44
45−toDocHelp :: Error -> [Error] -> [P.Doc]
45+toDocHelp :: Exit -> [Exit] -> [P.Doc]
46−toDocHelp e1 errs =
46+toDocHelp e1 exits =
47− case errs of
47+ case exits of
48 [] ->
48 [] ->
49− [errorToDoc e1]
49+ [exitToDoc e1]
50
50
51 e2 : otherErrors ->
51 e2 : otherErrors ->
52− errorToDoc e1 : separator (_name e1) (_name e2) : toDocHelp e2 otherErrors
52+ exitToDoc e1 : separator (_name e1) (_name e2) : toDocHelp e2 otherErrors
53
53
54
54
55−errorToDoc :: Error -> P.Doc
55+exitToDoc :: Exit -> P.Doc
56−errorToDoc (Error _name path _time source errors) =
56+exitToDoc (Exit _name path _time source errors) =
57 Compiler.errorsToDoc path source errors
57 Compiler.errorsToDoc path source errors
58
58
59
59
builder/src/Reporting/Error/Crawl.hs → builder/src/Reporting/Exit/Crawl.hsrenamed+8−9
@@ -1,7 +1,6 @@
1−{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
1{-# LANGUAGE OverloadedStrings #-}
3−module Reporting.Error.Crawl
2+module Reporting.Exit.Crawl
4− ( Error(..)
3+ ( Exit(..)
5 , Problem(..)
4 , Problem(..)
6 , Origin(..)
5 , Origin(..)
7 , toReport
6 , toReport
@@ -19,14 +18,14 @@ import Text.PrettyPrint.ANSI.Leijen ((<+>), (<>))
19import qualified Elm.Compiler as Compiler
18import qualified Elm.Compiler as Compiler
20import qualified Elm.Compiler.Module as Module
19import qualified Elm.Compiler.Module as Module
21import qualified Elm.Package as Pkg
20import qualified Elm.Package as Pkg
22−import qualified Reporting.Error.Help as Help
21+import qualified Reporting.Exit.Help as Help
23
22
24
23
25
24
26−-- ERROR
25+-- EXIT
27
26
28
27
29−data Error
28+data Exit
30 = RootFileNotFound FilePath
29 = RootFileNotFound FilePath
31 | RootModuleNameDuplicate Module.Raw [FilePath]
30 | RootModuleNameDuplicate Module.Raw [FilePath]
32 | RootNameless FilePath
31 | RootNameless FilePath
@@ -58,9 +57,9 @@ data Origin
58-- TO REPORT
57-- TO REPORT
59
58
60
59
61−toReport :: Error -> Help.Report
60+toReport :: Exit -> Help.Report
62−toReport err =
61+toReport exit =
63− case err of
62+ case exit of
64 RootFileNotFound path ->
63 RootFileNotFound path ->
65 Help.report "FILE NOT FOUND" Nothing
64 Help.report "FILE NOT FOUND" Nothing
66 "You want me to compile this file:"
65 "You want me to compile this file:"
builder/src/Reporting/Error/Deps.hs → builder/src/Reporting/Exit/Deps.hsrenamed+8−9
@@ -1,7 +1,6 @@
1−{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
1{-# LANGUAGE OverloadedStrings #-}
3−module Reporting.Error.Deps
2+module Reporting.Exit.Deps
4− ( Error(..)
3+ ( Exit(..)
5 , toReport
4 , toReport
6 )
5 )
7 where
6 where
@@ -12,14 +11,14 @@ import qualified Text.PrettyPrint.ANSI.Leijen as P
12import qualified Elm.Compiler as Compiler
11import qualified Elm.Compiler as Compiler
13import qualified Elm.Package as Pkg
12import qualified Elm.Package as Pkg
14import qualified Elm.Project.Constraint as Con
13import qualified Elm.Project.Constraint as Con
15−import qualified Reporting.Error.Help as Help
14+import qualified Reporting.Exit.Help as Help
16
15
17
16
18
17
19−-- ERRORS
18+-- EXITS
20
19
21
20
22−data Error
21+data Exit
23 = CorruptVersionCache Pkg.Name
22 = CorruptVersionCache Pkg.Name
24 | PackageNotFound Pkg.Name [Pkg.Name]
23 | PackageNotFound Pkg.Name [Pkg.Name]
25 -- verify
24 -- verify
@@ -33,9 +32,9 @@ data Error
33-- TO DOC
32-- TO DOC
34
33
35
34
36−toReport :: Error -> Help.Report
35+toReport :: Exit -> Help.Report
37−toReport err =
36+toReport exit =
38− case err of
37+ case exit of
39 CorruptVersionCache pkg ->
38 CorruptVersionCache pkg ->
40 Help.report "CORRUPT CACHE" Nothing
39 Help.report "CORRUPT CACHE" Nothing
41 ( "I ran into an unknown package while exploring dependencies:"
40 ( "I ran into an unknown package while exploring dependencies:"
builder/src/Reporting/Error/Diff.hs → builder/src/Reporting/Exit/Diff.hsrenamed+8−9
@@ -1,7 +1,6 @@
1−{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
1{-# LANGUAGE OverloadedStrings #-}
3−module Reporting.Error.Diff
2+module Reporting.Exit.Diff
4− ( Error(..)
3+ ( Exit(..)
5 , toReport
4 , toReport
6 )
5 )
7 where
6 where
@@ -10,14 +9,14 @@ import qualified Data.List as List
10import qualified Text.PrettyPrint.ANSI.Leijen as P
9import qualified Text.PrettyPrint.ANSI.Leijen as P
11
10
12import qualified Elm.Package as Pkg
11import qualified Elm.Package as Pkg
13−import qualified Reporting.Error.Help as Help
12+import qualified Reporting.Exit.Help as Help
14
13
15
14
16
15
17−-- ERRORS
16+-- EXITS
18
17
19
18
20−data Error
19+data Exit
21 = Application
20 = Application
22 | UnknownPackage Pkg.Name [Pkg.Name]
21 | UnknownPackage Pkg.Name [Pkg.Name]
23 | UnknownVersion Pkg.Name Pkg.Version [Pkg.Version]
22 | UnknownVersion Pkg.Name Pkg.Version [Pkg.Version]
@@ -27,9 +26,9 @@ data Error
27-- TO DOC
26-- TO DOC
28
27
29
28
30−toReport :: Error -> Help.Report
29+toReport :: Exit -> Help.Report
31−toReport err =
30+toReport exit =
32− case err of
31+ case exit of
33 Application ->
32 Application ->
34 Help.report "CANNOT DIFF APPLICATIONS" Nothing
33 Help.report "CANNOT DIFF APPLICATIONS" Nothing
35 "I cannot perform diffs on applications, only packages! If you are\
34 "I cannot perform diffs on applications, only packages! If you are\
builder/src/Reporting/Error/Help.hs → builder/src/Reporting/Exit/Help.hsrenamed+43−14
@@ -1,11 +1,11 @@
1−{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
1{-# LANGUAGE OverloadedStrings #-}
3−module Reporting.Error.Help
2+module Reporting.Exit.Help
4 ( Report
3 ( Report
5 , report
4 , report
6 , docReport
5 , docReport
7 , compilerReport
6 , compilerReport
8 , reportToDoc
7 , reportToDoc
8+ , reportToJson
9 , hintLink
9 , hintLink
10 , stack
10 , stack
11 , reflow
11 , reflow
@@ -16,7 +16,9 @@ module Reporting.Error.Help
16 )
16 )
17 where
17 where
18
18
19+
19import qualified Data.List as List
20import qualified Data.List as List
21+import qualified Data.Text as Text
20import GHC.IO.Handle (hIsTerminalDevice)
22import GHC.IO.Handle (hIsTerminalDevice)
21import System.IO (Handle, hPutStr, stderr, stdout)
23import System.IO (Handle, hPutStr, stderr, stdout)
22import qualified Text.PrettyPrint.ANSI.Leijen as P
24import qualified Text.PrettyPrint.ANSI.Leijen as P
@@ -24,6 +26,7 @@ import Text.PrettyPrint.ANSI.Leijen ((<>),(<+>))
24
26
25import qualified Elm.Compiler as Compiler
27import qualified Elm.Compiler as Compiler
26import qualified Elm.Package as Pkg
28import qualified Elm.Package as Pkg
29+import qualified Json.Encode as Encode
27
30
28
31
29
32
@@ -31,37 +34,40 @@ import qualified Elm.Package as Pkg
31
34
32
35
33data Report
36data Report
34− = FromCompiler P.Doc
37+ = CompileErrors
35 | Report
38 | Report
36 { _title :: String
39 { _title :: String
37 , _path :: Maybe FilePath
40 , _path :: Maybe FilePath
38− , _start :: P.Doc
41+ , _message :: P.Doc
39− , _others :: [P.Doc]
40 }
42 }
41
43
42
44
43report :: String -> Maybe FilePath -> String -> [P.Doc] -> Report
45report :: String -> Maybe FilePath -> String -> [P.Doc] -> Report
44−report title maybePath startString others =
46+report title path startString others =
45− Report title maybePath (P.text startString) others
47+ Report title path $ stack (reflow startString:others)
46
48
47
49
48docReport :: String -> Maybe FilePath -> P.Doc -> [P.Doc] -> Report
50docReport :: String -> Maybe FilePath -> P.Doc -> [P.Doc] -> Report
49−docReport =
51+docReport title path startDoc others =
50− Report
52+ Report title path $ stack (startDoc:others)
51
53
52
54
53compilerReport :: P.Doc -> Report
55compilerReport :: P.Doc -> Report
54compilerReport =
56compilerReport =
55− FromCompiler
57+ error "TODO compilerReport"
58+
59+
60+
61+-- TO DOC
56
62
57
63
58reportToDoc :: Report -> P.Doc
64reportToDoc :: Report -> P.Doc
59reportToDoc report_ =
65reportToDoc report_ =
60 case report_ of
66 case report_ of
61− FromCompiler doc ->
67+ CompileErrors ->
62− doc
68+ error "TODO reportToDoc"
63
69
64− Report title maybePath start others ->
70+ Report title maybePath message ->
65 let
71 let
66 makeDashes n =
72 makeDashes n =
67 replicate (max 1 (80 - n)) '-'
73 replicate (max 1 (80 - n)) '-'
@@ -78,7 +84,30 @@ reportToDoc report_ =
78 P.dullcyan $
84 P.dullcyan $
79 "--" <+> P.text title <+> P.text errorBarEnd
85 "--" <+> P.text title <+> P.text errorBarEnd
80 in
86 in
81− stack (errorBar : start : others ++ [""])
87+ stack [errorBar, message, ""]
88+
89+
90+
91+-- TO JSON
92+
93+
94+reportToJson :: Report -> Encode.Value
95+reportToJson report_ =
96+ case report_ of
97+ CompileErrors ->
98+ error "TODO reportToJson"
99+
100+ Report title maybePath message ->
101+ let
102+ messageString =
103+ P.displayS (P.renderPretty 1 80 message) ""
104+ in
105+ Encode.object
106+ [ ("type", Encode.text "error")
107+ , ("path", maybe Encode.null (Encode.text . Text.pack) maybePath)
108+ , ("title", Encode.text (Text.pack title))
109+ , ("message", Encode.text (Text.pack messageString))
110+ ]
82
111
83
112
84
113
builder/src/Reporting/Error/Http.hs → builder/src/Reporting/Exit/Http.hsrenamed+8−9
@@ -1,7 +1,6 @@
1−{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
1{-# LANGUAGE OverloadedStrings #-}
3−module Reporting.Error.Http
2+module Reporting.Exit.Http
4− ( Error(..)
3+ ( Exit(..)
5 , toReport
4 , toReport
6 , BadJson(..)
5 , BadJson(..)
7 , badJsonToDocs
6 , badJsonToDocs
@@ -13,14 +12,14 @@ import qualified Data.Text as Text
13import Text.PrettyPrint.ANSI.Leijen ((<>))
12import Text.PrettyPrint.ANSI.Leijen ((<>))
14import qualified Text.PrettyPrint.ANSI.Leijen as P
13import qualified Text.PrettyPrint.ANSI.Leijen as P
15
14
16−import qualified Reporting.Error.Help as Help
15+import qualified Reporting.Exit.Help as Help
17
16
18
17
19
18
20−-- ERRORS
19+-- EXITS
21
20
22
21
23−data Error
22+data Exit
24 = Unknown String
23 = Unknown String
25 | BadJson P.Doc
24 | BadJson P.Doc
26 | BadZipData
25 | BadZipData
@@ -31,13 +30,13 @@ data Error
31-- TO REPORT
30-- TO REPORT
32
31
33
32
34−toReport :: String -> Error -> Help.Report
33+toReport :: String -> Exit -> Help.Report
35−toReport url err =
34+toReport url exit =
36 let
35 let
37 urlDoc =
36 urlDoc =
38 P.indent 4 $ P.dullyellow $ "<" <> P.text url <> ">"
37 P.indent 4 $ P.dullyellow $ "<" <> P.text url <> ">"
39 in
38 in
40− case err of
39+ case exit of
41 Unknown message ->
40 Unknown message ->
42 Help.report "HTTP PROBLEM" Nothing "The following HTTP request failed:"
41 Help.report "HTTP PROBLEM" Nothing "The following HTTP request failed:"
43 [ urlDoc
42 [ urlDoc
builder/src/Reporting/Error/Publish.hs → builder/src/Reporting/Exit/Publish.hsrenamed+8−9
@@ -1,7 +1,6 @@
1−{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
1{-# LANGUAGE OverloadedStrings #-}
3−module Reporting.Error.Publish
2+module Reporting.Exit.Publish
4− ( Error(..)
3+ ( Exit(..)
5 , toReport
4 , toReport
6 )
5 )
7 where
6 where
@@ -12,14 +11,14 @@ import Text.PrettyPrint.ANSI.Leijen ((<>))
12
11
13import Deps.Diff (Magnitude, magnitudeToString)
12import Deps.Diff (Magnitude, magnitudeToString)
14import qualified Elm.Package as Pkg
13import qualified Elm.Package as Pkg
15−import qualified Reporting.Error.Help as Help
14+import qualified Reporting.Exit.Help as Help
16
15
17
16
18
17
19−-- ERRORS
18+-- EXITS
20
19
21
20
22−data Error
21+data Exit
23 = Application
22 = Application
24 | NotInitialVersion Pkg.Version
23 | NotInitialVersion Pkg.Version
25 | AlreadyPublished Pkg.Version
24 | AlreadyPublished Pkg.Version
@@ -39,9 +38,9 @@ data Error
39-- TO REPORT
38-- TO REPORT
40
39
41
40
42−toReport :: Error -> Help.Report
41+toReport :: Exit -> Help.Report
43−toReport err =
42+toReport exit =
44− case err of
43+ case exit of
45 Application ->
44 Application ->
46 Help.report "UNPUBLISHABLE" Nothing "I cannot publish applications, only packages!" []
45 Help.report "UNPUBLISHABLE" Nothing "I cannot publish applications, only packages!" []
47
46
builder/src/Reporting/Progress.hs+3−3
@@ -16,7 +16,7 @@ import Control.Concurrent.MVar (MVar, readMVar)
16import qualified Elm.Compiler.Module as Module
16import qualified Elm.Compiler.Module as Module
17import Deps.Diff (Magnitude)
17import Deps.Diff (Magnitude)
18import Elm.Package (Name, Version)
18import Elm.Package (Name, Version)
19−import Reporting.Error2 (Error)
19+import Reporting.Exit (Exit)
20
20
21
21
22
22
@@ -26,7 +26,7 @@ import Reporting.Error2 (Error)
26data Reporter =
26data Reporter =
27 Reporter
27 Reporter
28 { _tell :: Progress -> IO ()
28 { _tell :: Progress -> IO ()
29− , _end :: Maybe Error -> IO ()
29+ , _end :: Maybe Exit -> IO ()
30 }
30 }
31
31
32
32
@@ -47,7 +47,7 @@ makeReporter chan mvar =
47-- MESSAGES
47-- MESSAGES
48
48
49
49
50−data Msg = Progress Progress | End (Maybe Error)
50+data Msg = Progress Progress | End (Maybe Exit)
51
51
52
52
53data Progress
53data Progress
builder/src/Reporting/Progress/Repl.hs+5−6
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
2module Reporting.Progress.Repl
1module Reporting.Progress.Repl
3 ( create
2 ( create
4 )
3 )
@@ -9,7 +8,7 @@ import Control.Concurrent (forkIO)
9import Control.Concurrent.Chan (Chan, newChan, readChan)
8import Control.Concurrent.Chan (Chan, newChan, readChan)
10import Control.Concurrent.MVar (newEmptyMVar, putMVar)
9import Control.Concurrent.MVar (newEmptyMVar, putMVar)
11
10
12−import qualified Reporting.Error2 as Error
11+import qualified Reporting.Exit as Exit
13import qualified Reporting.Progress as Progress
12import qualified Reporting.Progress as Progress
14
13
15
14
@@ -36,10 +35,10 @@ loop chan =
36 Progress.Progress _ ->
35 Progress.Progress _ ->
37 loop chan
36 loop chan
38
37
39− Progress.End maybeError ->
38+ Progress.End maybeExit ->
40− case maybeError of
39+ case maybeExit of
41− Just err ->
40+ Just exit ->
42− Error.toStderr err
41+ Exit.toStderr exit
43
42
44 Nothing ->
43 Nothing ->
45 return ()
44 return ()
builder/src/Reporting/Progress/Terminal.hs+4−5
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
2module Reporting.Progress.Terminal
1module Reporting.Progress.Terminal
3 ( create
2 ( create
4 , newPackageOverview
3 , newPackageOverview
@@ -17,8 +16,8 @@ import qualified Elm.Package as Pkg
17import Elm.Package (Name, Version)
16import Elm.Package (Name, Version)
18
17
19import qualified Deps.Diff as Diff
18import qualified Deps.Diff as Diff
20−import qualified Reporting.Error2 as Error
19+import qualified Reporting.Exit as Exit
21−import qualified Reporting.Error.Help as Help
20+import qualified Reporting.Exit.Help as Help
22import Reporting.Progress (Msg(..), Progress(..), Outcome(..), PublishPhase(..), BumpPhase(..))
21import Reporting.Progress (Msg(..), Progress(..), Outcome(..), PublishPhase(..), BumpPhase(..))
23import qualified Reporting.Progress as Progress
22import qualified Reporting.Progress as Progress
24import qualified Reporting.Progress.Bar as Bar
23import qualified Reporting.Progress.Bar as Bar
@@ -56,8 +55,8 @@ loop :: Chan Msg -> State -> IO ()
56loop chan state =
55loop chan state =
57 do msg <- readChan chan
56 do msg <- readChan chan
58 case msg of
57 case msg of
59− End (Just err) ->
58+ End (Just exit) ->
60− Error.toStderr err
59+ Exit.toStderr exit
61
60
62 End Nothing ->
61 End Nothing ->
63 return ()
62 return ()
builder/src/Reporting/Task.hs+3−4
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
1{-# LANGUAGE OverloadedStrings #-}
3module Reporting.Task
2module Reporting.Task
4 ( Task, Task_, run, throw, mapError
3 ( Task, Task_, run, throw, mapError
@@ -31,7 +30,7 @@ import qualified System.IO as IO
31import Elm.Package (Name, Version)
30import Elm.Package (Name, Version)
32import qualified Elm.Package as Pkg
31import qualified Elm.Package as Pkg
33import qualified Elm.PerUserCache as PerUserCache
32import qualified Elm.PerUserCache as PerUserCache
34−import qualified Reporting.Error2 as Error
33+import qualified Reporting.Exit as Exit
35import qualified Reporting.Progress as Progress
34import qualified Reporting.Progress as Progress
36
35
37
36
@@ -40,7 +39,7 @@ import qualified Reporting.Progress as Progress
40
39
41
40
42type Task =
41type Task =
43− Task_ Error.Error
42+ Task_ Exit.Exit
44
43
45
44
46type Task_ e =
45type Task_ e =
@@ -184,7 +183,7 @@ initPool size =
184-- HTTP
183-- HTTP
185
184
186
185
187−runHttp :: (Http.Manager -> (Progress.Progress -> IO ()) -> IO (Either Error.Error a)) -> Task a
186+runHttp :: (Http.Manager -> (Progress.Progress -> IO ()) -> IO (Either Exit.Exit a)) -> Task a
188runHttp fetcher =
187runHttp fetcher =
189 do (Env _ _ manager tell) <- ask
188 do (Env _ _ manager tell) <- ask
190 result <- liftIO $ fetcher manager tell
189 result <- liftIO $ fetcher manager tell
builder/src/Reporting/Task/Http.hs+9−10
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE GADTs #-}
1{-# LANGUAGE GADTs #-}
3{-# LANGUAGE OverloadedStrings #-}
2{-# LANGUAGE OverloadedStrings #-}
4module Reporting.Task.Http
3module Reporting.Task.Http
@@ -24,8 +23,8 @@ import qualified Network.HTTP.Client as Http
24
23
25import qualified Elm.Compiler as Compiler
24import qualified Elm.Compiler as Compiler
26import qualified Elm.Package as Pkg
25import qualified Elm.Package as Pkg
27−import qualified Reporting.Error2 as Error
26+import qualified Reporting.Exit as Exit
28−import qualified Reporting.Error.Http as E
27+import qualified Reporting.Exit.Http as E
29import qualified Reporting.Progress as Progress
28import qualified Reporting.Progress as Progress
30import qualified Reporting.Task as Task
29import qualified Reporting.Task as Task
31
30
@@ -43,7 +42,7 @@ data Fetch a where
43
42
44
43
45type Handler a =
44type Handler a =
46− Http.Request -> Http.Manager -> IO (Either E.Error a)
45+ Http.Request -> Http.Manager -> IO (Either E.Exit a)
47
46
48
47
49package :: String -> [(String,String)] -> Handler a -> Fetch a
48package :: String -> [(String,String)] -> Handler a -> Fetch a
@@ -83,7 +82,7 @@ run fetch =
83 readMVar =<< runHelp chan manager tell fetch
82 readMVar =<< runHelp chan manager tell fetch
84
83
85
84
86−runHelp :: Chan (IO ()) -> Http.Manager -> (Progress.Progress -> IO ()) -> Fetch a -> IO (MVar (Either Error.Error a))
85+runHelp :: Chan (IO ()) -> Http.Manager -> (Progress.Progress -> IO ()) -> Fetch a -> IO (MVar (Either Exit.Exit a))
87runHelp chan manager tell fetch =
86runHelp chan manager tell fetch =
88 case fetch of
87 case fetch of
89 Package path params handler ->
88 Package path params handler ->
@@ -162,13 +161,13 @@ versionParam =
162-- HTTP HELP
161-- HTTP HELP
163
162
164
163
165−fetchSafe :: String -> Http.Manager -> Handler a -> IO (Either Error.Error a)
164+fetchSafe :: String -> Http.Manager -> Handler a -> IO (Either Exit.Exit a)
166fetchSafe url manager handler =
165fetchSafe url manager handler =
167 fetchUnsafe url manager handler
166 fetchUnsafe url manager handler
168 `catch` \e -> handleAnyError url (e :: SomeException)
167 `catch` \e -> handleAnyError url (e :: SomeException)
169
168
170
169
171−fetchUnsafe :: String -> Http.Manager -> Handler a -> IO (Either Error.Error a)
170+fetchUnsafe :: String -> Http.Manager -> Handler a -> IO (Either Exit.Exit a)
172fetchUnsafe url manager handler =
171fetchUnsafe url manager handler =
173 do request <- Http.parseUrlThrow url
172 do request <- Http.parseUrlThrow url
174 result <- handler request manager
173 result <- handler request manager
@@ -177,9 +176,9 @@ fetchUnsafe url manager handler =
177 return (Right value)
176 return (Right value)
178
177
179 Left problem ->
178 Left problem ->
180− return (Left (Error.BadHttp url problem))
179+ return (Left (Exit.BadHttp url problem))
181
180
182
181
183−handleAnyError :: (Exception e) => String -> e -> IO (Either Error.Error a)
182+handleAnyError :: (Exception e) => String -> e -> IO (Either Exit.Exit a)
184handleAnyError url exception =
183handleAnyError url exception =
185− return $ Left $ Error.BadHttp url $ E.Unknown $ show exception
184+ return $ Left $ Exit.BadHttp url $ E.Unknown $ show exception