Skip to content

Commit d27bdda

Browse files
committed
Prettify bump errors.
1 parent f06bd01 commit d27bdda

File tree

4 files changed

+65
-8
lines changed

4 files changed

+65
-8
lines changed

src/Main.gren

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,8 @@ parseUserArgs model compilerPath =
434434
(\err ->
435435
Terminal.Help.prettyPrint printOpts err
436436
|> Stream.Log.string model.stderr
437-
|> Task.map (\_ -> Cmd.none)
437+
|> Task.execute
438+
|> Task.succeed
438439
)
439440
|> Task.executeCmd
440441

@@ -467,7 +468,8 @@ parseUserArgs model compilerPath =
467468
(\err ->
468469
Terminal.Help.prettyPrint printOpts err
469470
|> Stream.Log.string model.stderr
470-
|> Task.map (\_ -> Cmd.none)
471+
|> Task.execute
472+
|> Task.succeed
471473
)
472474
|> Task.executeCmd
473475

@@ -529,7 +531,8 @@ parseUserArgs model compilerPath =
529531
(\err ->
530532
Terminal.Help.prettyPrint printOpts err
531533
|> Stream.Log.string model.stderr
532-
|> Task.map (\_ -> Cmd.none)
534+
|> Task.execute
535+
|> Task.succeed
533536
)
534537
|> Task.executeCmd
535538

@@ -654,7 +657,7 @@ parseUserArgs model compilerPath =
654657

655658
CliParser.PackageBump ->
656659
Terminal.PackageInstall.readProjectOutline model.fsPermission
657-
|> Task.mapError Debug.toString
660+
|> Task.mapError Terminal.PackageInstall.prettifyProjectOutlineError
658661
|> Task.andThen
659662
(\projectOutline ->
660663
Terminal.PackageBump.run
@@ -666,7 +669,7 @@ parseUserArgs model compilerPath =
666669
, stdin = model.stdin
667670
}
668671
projectOutline
669-
|> Task.mapError Debug.toString
672+
|> Task.mapError Terminal.PackageBump.prettifyError
670673
)
671674
|> Task.map
672675
(\backendFlags ->
@@ -683,7 +686,8 @@ parseUserArgs model compilerPath =
683686
)
684687
|> Task.onError
685688
(\err ->
686-
Stream.Log.line model.stdout err
689+
Terminal.Help.prettyPrint printOpts err
690+
|> Stream.Log.string model.stderr
687691
|> Task.execute
688692
|> Task.succeed
689693
)

src/Terminal/PackageBump.gren

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module Terminal.PackageBump exposing
44
, Error (..)
55
, Result
66
, run
7+
, prettifyError
78
)
89

910

@@ -27,6 +28,8 @@ import Json.Encode as Json
2728
import Json.Decode as Decode exposing (Decoder)
2829
import Stream.Extra
2930
import Terminal.PackageInstall
31+
import Terminal.Help as Help
32+
import CLI.PrettyPrinter as PP
3033

3134

3235
type alias Config =
@@ -167,3 +170,54 @@ run config { projectPath, outline } =
167170
)
168171

169172

173+
174+
prettifyError : Error -> PP.Document
175+
prettifyError error =
176+
when error is
177+
CannotBumpApplications ->
178+
Help.report
179+
"CANNOT BUMP APPLICATIONS"
180+
Nothing
181+
( PP.words
182+
"""
183+
This project is defined as an application, so there is no version number to bump.
184+
"""
185+
)
186+
187+
CurrentVersionUnpublished ->
188+
Help.report
189+
"CURRENT VERSION IS NOT PUBLISHED"
190+
Nothing
191+
( PP.words
192+
"""
193+
The version you're trying to bump from doesn't seem to exist in the remote repository.
194+
"""
195+
)
196+
197+
PreviousPackageCorruption ->
198+
Help.report
199+
"CANNOT BUILD PREVIOUS VERSION"
200+
Nothing
201+
( PP.verticalBlock
202+
[ PP.words
203+
"""
204+
In order to know what the next version of your package should be, I try to compare your current
205+
code with the previous version of this package.
206+
"""
207+
, PP.empty
208+
, PP.words
209+
"""
210+
However, I'm unable to build the previous version. Maybe the previous version was built with an
211+
older and incompatible compiler, or the package is corrupt in some way?
212+
"""
213+
]
214+
)
215+
216+
InstallError installErr ->
217+
Terminal.PackageInstall.prettifyError installErr
218+
219+
VersionFetchError gitError ->
220+
Git.report
221+
"FAILED TO FETCH VERSIONS FOR PACKAGE"
222+
"I was attempting to fetch available versions for this package"
223+
gitError

src/Terminal/PackageOutdated.gren

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,5 +135,5 @@ prettifyError error =
135135
FailedToFetchVersions { package, error = gitError } ->
136136
Git.report
137137
"FAILED TO FETCH VERSIONS FOR PACKAGE"
138-
("I was attempting the fetch available versions for " ++ PackageName.toString package)
138+
("I was attempting to fetch available versions for " ++ PackageName.toString package)
139139
gitError

src/Terminal/PackageUninstall.gren

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,3 @@ prettifyError error =
216216
|> PP.indent
217217
]
218218
)
219-

0 commit comments

Comments
 (0)