elm-pages 3.0.0-beta.15 → 3.0.0-beta.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +1 -1
  2. package/codegen/elm-pages-codegen.js +66 -115
  3. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-DeadCodeEliminateData.elmo +0 -0
  4. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-DeadCodeEliminateDataTest.elmo +0 -0
  5. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
  6. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/Runner.elm.js +20 -20
  7. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
  8. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_supervisor.js +1 -1
  9. package/generator/dead-code-review/src/Pages/Review/DeadCodeEliminateData.elm +5 -5
  10. package/generator/dead-code-review/tests/Pages/Review/DeadCodeEliminateDataTest.elm +21 -21
  11. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
  12. package/generator/review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
  13. package/generator/review/elm-stuff/tests-0.19.1/js/node_supervisor.js +1 -1
  14. package/generator/src/RouteBuilder.elm +23 -23
  15. package/generator/src/SharedTemplate.elm +2 -2
  16. package/generator/src/SiteConfig.elm +2 -2
  17. package/generator/src/build.js +7 -7
  18. package/generator/src/cli.js +11 -8
  19. package/generator/src/compatibility-key.js +1 -1
  20. package/generator/src/dev-server.js +6 -6
  21. package/generator/src/render-test.js +1 -1
  22. package/generator/src/render.js +5 -5
  23. package/generator/src/request-cache.js +5 -5
  24. package/package.json +1 -1
  25. package/src/ApiRoute.elm +13 -13
  26. package/src/BackendTask/{Port.elm → Custom.elm} +60 -52
  27. package/src/BackendTask/Env.elm +9 -8
  28. package/src/BackendTask/File.elm +49 -10
  29. package/src/BackendTask/Glob.elm +6 -6
  30. package/src/BackendTask/Http.elm +12 -12
  31. package/src/BackendTask.elm +9 -23
  32. package/src/{Exception.elm → FatalError.elm} +37 -31
  33. package/src/Form.elm +3 -3
  34. package/src/Internal/ApiRoute.elm +5 -5
  35. package/src/Pages/Generate.elm +1 -1
  36. package/src/Pages/Internal/FatalError.elm +5 -0
  37. package/src/Pages/Internal/Platform/Cli.elm +4 -4
  38. package/src/Pages/Internal/Platform/CompatibilityKey.elm +1 -1
  39. package/src/Pages/Internal/Platform/GeneratorApplication.elm +7 -7
  40. package/src/Pages/Internal/Platform/StaticResponses.elm +10 -9
  41. package/src/Pages/Internal/Script.elm +2 -2
  42. package/src/Pages/Manifest.elm +2 -2
  43. package/src/Pages/ProgramConfig.elm +7 -7
  44. package/src/Pages/Script.elm +4 -4
  45. package/src/Pages/SiteConfig.elm +2 -2
  46. package/src/Server/Request.elm +3 -3
@@ -104,7 +104,7 @@ import Base64
104
104
  import Bytes exposing (Bytes)
105
105
  import Bytes.Decode
106
106
  import Dict exposing (Dict)
107
- import Exception exposing (Exception)
107
+ import FatalError exposing (FatalError, Recoverable)
108
108
  import Json.Decode
109
109
  import Json.Encode as Encode
110
110
  import Pages.Internal.StaticHttpBody as Body
@@ -157,10 +157,10 @@ type alias Body =
157
157
 
158
158
  import BackendTask
159
159
  import BackendTask.Http
160
- import Exception exposing (Exception)
160
+ import FatalError exposing (FatalError)
161
161
  import Json.Decode as Decode exposing (Decoder)
162
162
 
163
- getRequest : BackendTask (Exception Error) Int
163
+ getRequest : BackendTask (FatalError Error) Int
164
164
  getRequest =
165
165
  BackendTask.Http.getJson
166
166
  "https://api.github.com/repos/dillonkearns/elm-pages"
@@ -170,7 +170,7 @@ type alias Body =
170
170
  getJson :
171
171
  String
172
172
  -> Json.Decode.Decoder a
173
- -> BackendTask (Exception Error) a
173
+ -> BackendTask (Recoverable Error) a
174
174
  getJson url decoder =
175
175
  getWithOptions
176
176
  { url = url
@@ -189,9 +189,9 @@ use the more flexible `getWithOptions`.
189
189
 
190
190
  import BackendTask
191
191
  import BackendTask.Http
192
- import Exception exposing (Exception)
192
+ import FatalError exposing (FatalError)
193
193
 
194
- getRequest : BackendTask (Exception Error) String
194
+ getRequest : BackendTask (FatalError Error) String
195
195
  getRequest =
196
196
  BackendTask.Http.get
197
197
  "https://api.github.com/repos/dillonkearns/elm-pages"
@@ -201,7 +201,7 @@ use the more flexible `getWithOptions`.
201
201
  get :
202
202
  String
203
203
  -> Expect a
204
- -> BackendTask (Exception Error) a
204
+ -> BackendTask { fatal : FatalError, recoverable : Error } a
205
205
  get url expect =
206
206
  getWithOptions
207
207
  { url = url
@@ -231,7 +231,7 @@ getWithOptions :
231
231
  , timeoutInMs : Maybe Int
232
232
  , cachePath : Maybe String
233
233
  }
234
- -> BackendTask (Exception Error) a
234
+ -> BackendTask (Recoverable Error) a
235
235
  getWithOptions request__ =
236
236
  let
237
237
  request_ : HashRequest.Request
@@ -258,7 +258,7 @@ post :
258
258
  String
259
259
  -> Body
260
260
  -> Expect a
261
- -> BackendTask (Exception Error) a
261
+ -> BackendTask (Recoverable Error) a
262
262
  post url body expect =
263
263
  request
264
264
  { url = url
@@ -397,7 +397,7 @@ request :
397
397
  , timeoutInMs : Maybe Int
398
398
  }
399
399
  -> Expect a
400
- -> BackendTask (Exception Error) a
400
+ -> BackendTask (Recoverable Error) a
401
401
  request request__ expect =
402
402
  let
403
403
  request_ : HashRequest.Request
@@ -475,7 +475,7 @@ with this as a low-level detail, or you can use functions like [BackendTask.Http
475
475
  requestRaw :
476
476
  HashRequest.Request
477
477
  -> Expect a
478
- -> BackendTask (Exception Error) a
478
+ -> BackendTask (Recoverable Error) a
479
479
  requestRaw request__ expect =
480
480
  let
481
481
  request_ : HashRequest.Request
@@ -573,7 +573,7 @@ requestRaw request__ expect =
573
573
  |> BackendTask.fromResult
574
574
  |> BackendTask.mapError
575
575
  (\error ->
576
- Exception.Exception error (errorToString error)
576
+ FatalError.recoverable (errorToString error) error
577
577
  )
578
578
  )
579
579
 
@@ -5,7 +5,7 @@ module BackendTask exposing
5
5
  , andThen, resolve, combine
6
6
  , andMap
7
7
  , map2, map3, map4, map5, map6, map7, map8, map9
8
- , catch, throw, mapError, onError, toResult
8
+ , allowFatal, mapError, onError, toResult
9
9
  )
10
10
 
11
11
  {-| In an `elm-pages` app, each Route Module can define a value `data` which is a `BackendTask` that will be resolved **before** `init` is called. That means it is also available
@@ -16,7 +16,7 @@ A `BackendTask` lets you pull in data from:
16
16
  - Local files ([`BackendTask.File`](BackendTask-File))
17
17
  - HTTP requests ([`BackendTask.Http`](BackendTask-Http))
18
18
  - Globs, i.e. listing out local files based on a pattern like `content/*.txt` ([`BackendTask.Glob`](BackendTask-Glob))
19
- - Ports, i.e. getting JSON data from running custom NodeJS, similar to a port in a vanilla Elm app except run at build-time in NodeJS, rather than at run-time in the browser ([`BackendTask.Port`](BackendTask-Port))
19
+ - Ports, i.e. getting JSON data from running custom NodeJS, similar to a port in a vanilla Elm app except run at build-time in NodeJS, rather than at run-time in the browser ([`BackendTask.Custom`](BackendTask-Custom))
20
20
  - Hardcoded data (`BackendTask.succeed "Hello!"`)
21
21
  - Or any combination of the above, using `BackendTask.map2`, `BackendTask.andThen`, or other combining/continuing helpers from this module
22
22
 
@@ -80,13 +80,13 @@ Any place in your `elm-pages` app where the framework lets you pass in a value o
80
80
  @docs map2, map3, map4, map5, map6, map7, map8, map9
81
81
 
82
82
 
83
- ## Exception Handling
83
+ ## FatalError Handling
84
84
 
85
- @docs catch, throw, mapError, onError, toResult
85
+ @docs allowFatal, mapError, onError, toResult
86
86
 
87
87
  -}
88
88
 
89
- import Exception exposing (Exception(..), Throwable)
89
+ import FatalError exposing (FatalError)
90
90
  import Json.Encode
91
91
  import Pages.StaticHttpRequest exposing (RawRequest(..))
92
92
 
@@ -524,28 +524,14 @@ map9 combineFn request1 request2 request3 request4 request5 request6 request7 re
524
524
 
525
525
 
526
526
  {-| -}
527
- catch : BackendTask (Exception error) value -> BackendTask error value
528
- catch ds =
529
- ds
530
- |> onError
531
- (\exception ->
532
- case exception of
533
- Exception error _ ->
534
- fail error
535
- )
536
-
537
-
538
- {-| -}
539
- throw : BackendTask (Exception error) data -> BackendTask Throwable data
540
- throw backendTask =
541
- backendTask
542
- |> onError (Exception.throw >> fail)
527
+ allowFatal : BackendTask { error | fatal : FatalError } data -> BackendTask FatalError data
528
+ allowFatal backendTask =
529
+ mapError .fatal backendTask
543
530
 
544
531
 
545
532
  {-| -}
546
- toResult : BackendTask (Exception error) data -> BackendTask noError (Result error data)
533
+ toResult : BackendTask error data -> BackendTask noError (Result error data)
547
534
  toResult backendTask =
548
535
  backendTask
549
- |> catch
550
536
  |> andThen (Ok >> succeed)
551
537
  |> onError (Err >> succeed)
@@ -1,13 +1,16 @@
1
- module Exception exposing (Throwable, Exception(..), fromString, fromStringWithValue, throw, unwrap)
1
+ module FatalError exposing
2
+ ( FatalError, fromString, recoverable
3
+ , Recoverable
4
+ )
2
5
 
3
6
  {-| The Elm language doesn't have the concept of exceptions or special control flow for errors. It just has
4
7
  Custom Types, and by convention types like `Result` and the `Err` variant are used to represent possible failure states
5
8
  and combine together different error states.
6
9
 
7
10
  `elm-pages` doesn't change that, Elm still doesn't have special exception control flow at the language level. It does have
8
- a type, which is just a regular old Elm type, called `Exception`. Why? Because this plain old Elm type does have one
11
+ a type, which is just a regular old Elm type, called `FatalError`. Why? Because this plain old Elm type does have one
9
12
  special characteristic - the `elm-pages` framework knows how to turn it into an error message. This becomes interesting
10
- because an `elm-pages` app has several places that accept a value of type `BackendTask Exception.Throwable value`.
13
+ because an `elm-pages` app has several places that accept a value of type `BackendTask FatalError.FatalError value`.
11
14
  This design lets the `elm-pages` framework do some of the work for you.
12
15
 
13
16
  For example, if you wanted to handle possible errors to present them to the user
@@ -15,34 +18,34 @@ For example, if you wanted to handle possible errors to present them to the user
15
18
  type alias Data =
16
19
  String
17
20
 
18
- data : RouteParams -> BackendTask Throwable Data
21
+ data : RouteParams -> BackendTask FatalError Data
19
22
  data routeParams =
20
23
  BackendTask.Http.getJson "https://api.github.com/repos/dillonkearns/elm-pages"
21
24
  (Decode.field "description" Decode.string)
22
25
  |> BackendTask.onError
23
26
  (\error ->
24
- case Exception.unwrap error of
27
+ case FatalError.unwrap error of
25
28
  BackendTask.Http.BadStatus metadata string ->
26
29
  if metadata.statusCode == 401 || metadata.statusCode == 403 || metadata.statusCode == 404 then
27
30
  BackendTask.succeed "Either this repo doesn't exist or you don't have access to it."
28
31
 
29
32
  else
30
33
  -- we're only handling these expected error cases. In the case of an HTTP timeout,
31
- -- we'll let the error propagate as a Throwable
32
- BackendTask.fail error |> BackendTask.throw
34
+ -- we'll let the error propagate as a FatalError
35
+ BackendTask.fail error |> BackendTask.allowFatal
33
36
 
34
37
  _ ->
35
- BackendTask.fail error |> BackendTask.throw
38
+ BackendTask.fail error |> BackendTask.allowFatal
36
39
  )
37
40
 
38
41
  This can be a lot of work for all possible errors, though. If you don't expect this kind of error (it's an _exceptional_ case),
39
42
  you can let the framework handle it if the error ever does unexpectedly occur.
40
43
 
41
- data : RouteParams -> BackendTask Throwable Data
44
+ data : RouteParams -> BackendTask FatalError Data
42
45
  data routeParams =
43
46
  BackendTask.Http.getJson "https://api.github.com/repos/dillonkearns/elm-pages"
44
47
  (Decode.field "description" Decode.string)
45
- |> BackendTask.throw
48
+ |> BackendTask.allowFatal
46
49
 
47
50
  This is especially useful for pages generated at build-time (`RouteBuilder.preRender`) where you want the build
48
51
  to fail if anything unexpected happens. With pre-rendered routes, you know that these error cases won't
@@ -54,42 +57,45 @@ issue.
54
57
  In the case of server-rendered Routes (`RouteBuilder.serverRender`), `elm-pages` will show your 500 error page
55
58
  when these errors occur.
56
59
 
57
- @docs Throwable, Exception, fromString, fromStringWithValue, throw, unwrap
60
+ @docs FatalError, fromString, recoverable
58
61
 
59
- -}
62
+ @docs Recoverable
60
63
 
64
+ -}
61
65
 
62
- {-| -}
63
- type alias Throwable =
64
- Exception ()
66
+ import Pages.Internal.FatalError
65
67
 
66
68
 
67
69
  {-| -}
68
- type Exception error
69
- = Exception error { title : String, body : String }
70
+ type alias Recoverable error =
71
+ { fatal : FatalError
72
+ , recoverable : error
73
+ }
70
74
 
71
75
 
72
76
  {-| -}
73
- fromString : String -> Exception ()
74
- fromString string =
75
- fromStringWithValue string ()
77
+ type alias FatalError =
78
+ Pages.Internal.FatalError.FatalError
76
79
 
77
80
 
78
81
  {-| -}
79
- fromStringWithValue : String -> value -> Exception value
80
- fromStringWithValue string value =
81
- Exception value { title = "Custom Error", body = string }
82
+ build : { title : String, body : String } -> FatalError
83
+ build info =
84
+ Pages.Internal.FatalError.FatalError info
82
85
 
83
86
 
84
87
  {-| -}
85
- throw : Exception error -> Exception ()
86
- throw exception =
87
- case exception of
88
- Exception _ string ->
89
- Exception () string
88
+ fromString : String -> FatalError
89
+ fromString string =
90
+ build
91
+ { title = "Custom Error"
92
+ , body = string
93
+ }
90
94
 
91
95
 
92
96
  {-| -}
93
- unwrap : Exception error -> error
94
- unwrap (Exception error _) =
95
- error
97
+ recoverable : { title : String, body : String } -> value -> Recoverable value
98
+ recoverable info value =
99
+ { fatal = build info
100
+ , recoverable = value
101
+ }
package/src/Form.elm CHANGED
@@ -269,7 +269,7 @@ Totally customizable. Uses [`Form.FieldView`](Form-FieldView) to render all of t
269
269
 
270
270
  import BackendTask exposing (BackendTask)
271
271
  import Dict exposing (Dict)
272
- import Exception exposing (Throwable)
272
+ import FatalError exposing (FatalError)
273
273
  import Form.Field as Field exposing (Field(..))
274
274
  import Form.FieldStatus as FieldStatus exposing (FieldStatus)
275
275
  import Form.FieldView
@@ -682,7 +682,7 @@ toServerForm :
682
682
  ->
683
683
  Form
684
684
  error
685
- { combine : Validation.Validation error (BackendTask Throwable (Validation.Validation error combined kind constraints)) kind constraints
685
+ { combine : Validation.Validation error (BackendTask FatalError (Validation.Validation error combined kind constraints)) kind constraints
686
686
  , view : viewFn
687
687
  }
688
688
  data
@@ -695,7 +695,7 @@ toServerForm (Form a b c) =
695
695
  { result : Dict String (List error)
696
696
  , isMatchCandidate : Bool
697
697
  , combineAndView :
698
- { combine : Validation.Validation error (BackendTask Throwable (Validation.Validation error combined kind constraints)) kind constraints
698
+ { combine : Validation.Validation error (BackendTask FatalError (Validation.Validation error combined kind constraints)) kind constraints
699
699
  , view : viewFn
700
700
  }
701
701
  }
@@ -9,7 +9,7 @@ module Internal.ApiRoute exposing
9
9
  )
10
10
 
11
11
  import BackendTask exposing (BackendTask)
12
- import Exception exposing (Throwable)
12
+ import FatalError exposing (FatalError)
13
13
  import Head
14
14
  import Json.Decode
15
15
  import Pattern exposing (Pattern)
@@ -46,12 +46,12 @@ tryMatchDone path (ApiRoute handler) =
46
46
  type ApiRoute response
47
47
  = ApiRoute
48
48
  { regex : Regex
49
- , matchesToResponse : Json.Decode.Value -> String -> BackendTask Throwable (Maybe response)
50
- , buildTimeRoutes : BackendTask Throwable (List String)
51
- , handleRoute : String -> BackendTask Throwable Bool
49
+ , matchesToResponse : Json.Decode.Value -> String -> BackendTask FatalError (Maybe response)
50
+ , buildTimeRoutes : BackendTask FatalError (List String)
51
+ , handleRoute : String -> BackendTask FatalError Bool
52
52
  , pattern : Pattern
53
53
  , kind : String
54
- , globalHeadTags : Maybe (BackendTask Throwable (List Head.Tag))
54
+ , globalHeadTags : Maybe (BackendTask FatalError (List Head.Tag))
55
55
  }
56
56
 
57
57
 
@@ -1409,6 +1409,6 @@ throwableTask : Elm.Annotation.Annotation -> Elm.Annotation.Annotation
1409
1409
  throwableTask dataType =
1410
1410
  Elm.Annotation.namedWith [ "BackendTask" ]
1411
1411
  "BackendTask"
1412
- [ Elm.Annotation.named [ "Exception" ] "Throwable"
1412
+ [ Elm.Annotation.named [ "FatalError" ] "FatalError"
1413
1413
  , dataType
1414
1414
  ]
@@ -0,0 +1,5 @@
1
+ module Pages.Internal.FatalError exposing (FatalError(..))
2
+
3
+
4
+ type FatalError
5
+ = FatalError { title : String, body : String }
@@ -12,7 +12,7 @@ import Bytes exposing (Bytes)
12
12
  import Bytes.Encode
13
13
  import Codec
14
14
  import Dict
15
- import Exception exposing (Throwable)
15
+ import FatalError exposing (FatalError)
16
16
  import Head exposing (Tag)
17
17
  import Html exposing (Html)
18
18
  import HtmlPrinter
@@ -51,7 +51,7 @@ currentCompatibilityKey =
51
51
 
52
52
  {-| -}
53
53
  type alias Model route =
54
- { staticResponses : BackendTask Throwable Effect
54
+ { staticResponses : BackendTask FatalError Effect
55
55
  , errors : List BuildError
56
56
  , maybeRequestJson : RenderRequest route
57
57
  , isDevServer : Bool
@@ -376,11 +376,11 @@ initLegacy :
376
376
  -> ( Model route, Effect )
377
377
  initLegacy site ((RenderRequest.SinglePage includeHtml singleRequest _) as renderRequest) { isDevServer } config =
378
378
  let
379
- globalHeadTags : BackendTask Throwable (List Tag)
379
+ globalHeadTags : BackendTask FatalError (List Tag)
380
380
  globalHeadTags =
381
381
  (config.globalHeadTags |> Maybe.withDefault (\_ -> BackendTask.succeed [])) HtmlPrinter.htmlToString
382
382
 
383
- staticResponsesNew : BackendTask Throwable Effect
383
+ staticResponsesNew : BackendTask FatalError Effect
384
384
  staticResponsesNew =
385
385
  StaticResponses.renderApiRequest
386
386
  (case singleRequest of
@@ -3,4 +3,4 @@ module Pages.Internal.Platform.CompatibilityKey exposing (currentCompatibilityKe
3
3
 
4
4
  currentCompatibilityKey : Int
5
5
  currentCompatibilityKey =
6
- 5
6
+ 6
@@ -11,7 +11,7 @@ import BuildError exposing (BuildError)
11
11
  import Cli.Program as Program exposing (FlagsIncludingArgv)
12
12
  import Codec
13
13
  import Dict
14
- import Exception exposing (Throwable)
14
+ import FatalError exposing (FatalError)
15
15
  import HtmlPrinter
16
16
  import Json.Decode as Decode
17
17
  import Json.Encode as Encode
@@ -33,7 +33,7 @@ type alias Flags =
33
33
 
34
34
  {-| -}
35
35
  type alias Model =
36
- { staticResponses : BackendTask Throwable ()
36
+ { staticResponses : BackendTask FatalError ()
37
37
  , errors : List BuildError
38
38
  }
39
39
 
@@ -47,10 +47,10 @@ type Msg
47
47
  {-| -}
48
48
  app :
49
49
  GeneratorProgramConfig
50
- -> Program.StatefulProgram Model Msg (BackendTask Throwable ()) Flags
50
+ -> Program.StatefulProgram Model Msg (BackendTask FatalError ()) Flags
51
51
  app config =
52
52
  let
53
- cliConfig : Program.Config (BackendTask Throwable ())
53
+ cliConfig : Program.Config (BackendTask FatalError ())
54
54
  cliConfig =
55
55
  case config.data of
56
56
  Pages.Internal.Script.Script theCliConfig ->
@@ -246,7 +246,7 @@ perform config effect =
246
246
 
247
247
  {-| -}
248
248
  init :
249
- BackendTask Throwable ()
249
+ BackendTask FatalError ()
250
250
  -> FlagsIncludingArgv Flags
251
251
  -> ( Model, Effect )
252
252
  init execute flags =
@@ -282,11 +282,11 @@ init execute flags =
282
282
 
283
283
 
284
284
  initLegacy :
285
- BackendTask Throwable ()
285
+ BackendTask FatalError ()
286
286
  -> ( Model, Effect )
287
287
  initLegacy execute =
288
288
  let
289
- staticResponses : BackendTask Throwable ()
289
+ staticResponses : BackendTask FatalError ()
290
290
  staticResponses =
291
291
  StaticResponses.renderApiRequest execute
292
292
 
@@ -2,35 +2,36 @@ module Pages.Internal.Platform.StaticResponses exposing (NextStep(..), empty, ne
2
2
 
3
3
  import BackendTask exposing (BackendTask)
4
4
  import BuildError exposing (BuildError)
5
- import Exception exposing (Exception(..), Throwable)
5
+ import FatalError exposing (FatalError)
6
6
  import List.Extra
7
+ import Pages.Internal.FatalError
7
8
  import Pages.StaticHttp.Request as HashRequest
8
9
  import Pages.StaticHttpRequest as StaticHttpRequest
9
10
  import RequestsAndPending exposing (RequestsAndPending)
10
11
  import TerminalText
11
12
 
12
13
 
13
- empty : a -> BackendTask Throwable a
14
+ empty : a -> BackendTask FatalError a
14
15
  empty a =
15
16
  BackendTask.succeed a
16
17
 
17
18
 
18
19
  renderApiRequest :
19
- BackendTask Throwable response
20
- -> BackendTask Throwable response
20
+ BackendTask FatalError response
21
+ -> BackendTask FatalError response
21
22
  renderApiRequest request =
22
23
  request
23
24
 
24
25
 
25
26
  type NextStep route value
26
- = Continue (List HashRequest.Request) (StaticHttpRequest.RawRequest Throwable value)
27
+ = Continue (List HashRequest.Request) (StaticHttpRequest.RawRequest FatalError value)
27
28
  | Finish value
28
29
  | FinishedWithErrors (List BuildError)
29
30
 
30
31
 
31
32
  nextStep :
32
33
  RequestsAndPending
33
- -> BackendTask Throwable a
34
+ -> BackendTask FatalError a
34
35
  ->
35
36
  { model
36
37
  | errors : List BuildError
@@ -38,7 +39,7 @@ nextStep :
38
39
  -> NextStep route a
39
40
  nextStep allRawResponses staticResponses { errors } =
40
41
  let
41
- staticRequestsStatus : StaticHttpRequest.Status Throwable a
42
+ staticRequestsStatus : StaticHttpRequest.Status FatalError a
42
43
  staticRequestsStatus =
43
44
  allRawResponses
44
45
  |> StaticHttpRequest.cacheRequestResolution staticResponses
@@ -63,7 +64,7 @@ nextStep allRawResponses staticResponses { errors } =
63
64
  StaticHttpRequest.HasPermanentError _ ->
64
65
  ( ( False, Nothing )
65
66
  , []
66
- , BackendTask.fail (Exception.fromString "TODO this shouldn't happen")
67
+ , BackendTask.fail (FatalError.fromString "TODO this shouldn't happen")
67
68
  )
68
69
  in
69
70
  if pendingRequests then
@@ -111,7 +112,7 @@ nextStep allRawResponses staticResponses { errors } =
111
112
  Just (Ok completed) ->
112
113
  Finish completed
113
114
 
114
- Just (Err (Exception () buildError)) ->
115
+ Just (Err (Pages.Internal.FatalError.FatalError buildError)) ->
115
116
  FinishedWithErrors
116
117
  [ { title = buildError.title |> String.toUpper
117
118
  , path = "" -- TODO include path here
@@ -2,7 +2,7 @@ module Pages.Internal.Script exposing (Script(..))
2
2
 
3
3
  import BackendTask exposing (BackendTask)
4
4
  import Cli.Program as Program
5
- import Exception exposing (Throwable)
5
+ import FatalError exposing (FatalError)
6
6
  import Html exposing (Html)
7
7
 
8
8
 
@@ -13,5 +13,5 @@ type Script
13
13
  -> Html Never
14
14
  -> String
15
15
  )
16
- -> Program.Config (BackendTask Throwable ())
16
+ -> Program.Config (BackendTask FatalError ())
17
17
  )
@@ -68,7 +68,7 @@ import BackendTask exposing (BackendTask)
68
68
  import Color exposing (Color)
69
69
  import Color.Convert
70
70
  import Dict exposing (Dict)
71
- import Exception exposing (Throwable)
71
+ import FatalError exposing (FatalError)
72
72
  import Head
73
73
  import Json.Encode as Encode
74
74
  import LanguageTag exposing (LanguageTag, emptySubtags)
@@ -345,7 +345,7 @@ nonEmptyList list =
345
345
 
346
346
  {-| A generator for Api.elm to include a manifest.json.
347
347
  -}
348
- generator : String -> BackendTask Throwable Config -> ApiRoute.ApiRoute ApiRoute.Response
348
+ generator : String -> BackendTask FatalError Config -> ApiRoute.ApiRoute ApiRoute.Response
349
349
  generator canonicalSiteUrl config =
350
350
  ApiRoute.succeed
351
351
  (config
@@ -7,7 +7,7 @@ import Bytes exposing (Bytes)
7
7
  import Bytes.Decode
8
8
  import Bytes.Encode
9
9
  import Dict exposing (Dict)
10
- import Exception exposing (Throwable)
10
+ import FatalError exposing (FatalError)
11
11
  import Form.FormData exposing (FormData)
12
12
  import Head
13
13
  import Html exposing (Html)
@@ -49,9 +49,9 @@ type alias ProgramConfig userMsg userModel route pageData actionData sharedData
49
49
  -> ( userModel, effect )
50
50
  , update : Pages.FormState.PageFormState -> Dict String (Pages.Transition.FetcherState actionData) -> Maybe Pages.Transition.Transition -> sharedData -> pageData -> Maybe Browser.Navigation.Key -> userMsg -> userModel -> ( userModel, effect )
51
51
  , subscriptions : route -> Path -> userModel -> Sub userMsg
52
- , sharedData : BackendTask Throwable sharedData
53
- , data : Decode.Value -> route -> BackendTask Throwable (PageServerResponse pageData errorPage)
54
- , action : Decode.Value -> route -> BackendTask Throwable (PageServerResponse actionData errorPage)
52
+ , sharedData : BackendTask FatalError sharedData
53
+ , data : Decode.Value -> route -> BackendTask FatalError (PageServerResponse pageData errorPage)
54
+ , action : Decode.Value -> route -> BackendTask FatalError (PageServerResponse actionData errorPage)
55
55
  , onActionData : actionData -> Maybe userMsg
56
56
  , view :
57
57
  Pages.FormState.PageFormState
@@ -69,8 +69,8 @@ type alias ProgramConfig userMsg userModel route pageData actionData sharedData
69
69
  { view : userModel -> { title : String, body : List (Html (Pages.Msg.Msg userMsg)) }
70
70
  , head : List Head.Tag
71
71
  }
72
- , handleRoute : route -> BackendTask Throwable (Maybe NotFoundReason)
73
- , getStaticRoutes : BackendTask Throwable (List route)
72
+ , handleRoute : route -> BackendTask FatalError (Maybe NotFoundReason)
73
+ , getStaticRoutes : BackendTask FatalError (List route)
74
74
  , urlToRoute : Url -> route
75
75
  , routeToPath : route -> List String
76
76
  , site : Maybe SiteConfig
@@ -102,7 +102,7 @@ type alias ProgramConfig userMsg userModel route pageData actionData sharedData
102
102
  , encodeResponse : ResponseSketch pageData actionData sharedData -> Bytes.Encode.Encoder
103
103
  , encodeAction : actionData -> Bytes.Encode.Encoder
104
104
  , decodeResponse : Bytes.Decode.Decoder (ResponseSketch pageData actionData sharedData)
105
- , globalHeadTags : Maybe ((Maybe { indent : Int, newLines : Bool } -> Html Never -> String) -> BackendTask Throwable (List Head.Tag))
105
+ , globalHeadTags : Maybe ((Maybe { indent : Int, newLines : Bool } -> Html Never -> String) -> BackendTask FatalError (List Head.Tag))
106
106
  , cmdToEffect : Cmd userMsg -> effect
107
107
  , perform :
108
108
  { fetchRouteData :
@@ -34,7 +34,7 @@ import BackendTask.Http
34
34
  import BackendTask.Internal.Request
35
35
  import Cli.OptionsParser as OptionsParser
36
36
  import Cli.Program as Program
37
- import Exception exposing (Exception, Throwable)
37
+ import FatalError exposing (FatalError, Recoverable)
38
38
  import Json.Decode as Decode
39
39
  import Json.Encode as Encode
40
40
  import Pages.Internal.Script
@@ -52,7 +52,7 @@ type Error
52
52
 
53
53
 
54
54
  {-| -}
55
- writeFile : { path : String, body : String } -> BackendTask (Exception Error) ()
55
+ writeFile : { path : String, body : String } -> BackendTask (Recoverable Error) ()
56
56
  writeFile { path, body } =
57
57
  BackendTask.Internal.Request.request
58
58
  { name = "write-file"
@@ -85,7 +85,7 @@ log message =
85
85
 
86
86
 
87
87
  {-| -}
88
- withoutCliOptions : BackendTask Throwable () -> Script
88
+ withoutCliOptions : BackendTask FatalError () -> Script
89
89
  withoutCliOptions execute =
90
90
  Pages.Internal.Script.Script
91
91
  (\_ ->
@@ -100,7 +100,7 @@ withoutCliOptions execute =
100
100
 
101
101
 
102
102
  {-| -}
103
- withCliOptions : Program.Config cliOptions -> (cliOptions -> BackendTask Throwable ()) -> Script
103
+ withCliOptions : Program.Config cliOptions -> (cliOptions -> BackendTask FatalError ()) -> Script
104
104
  withCliOptions config execute =
105
105
  Pages.Internal.Script.Script
106
106
  (\_ ->
@@ -1,11 +1,11 @@
1
1
  module Pages.SiteConfig exposing (SiteConfig)
2
2
 
3
3
  import BackendTask exposing (BackendTask)
4
- import Exception exposing (Throwable)
4
+ import FatalError exposing (FatalError)
5
5
  import Head
6
6
 
7
7
 
8
8
  type alias SiteConfig =
9
9
  { canonicalUrl : String
10
- , head : BackendTask Throwable (List Head.Tag)
10
+ , head : BackendTask FatalError (List Head.Tag)
11
11
  }