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

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 (42) 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/cli.js +2 -2
  18. package/generator/src/compatibility-key.js +1 -1
  19. package/generator/src/render.js +5 -5
  20. package/package.json +1 -1
  21. package/src/ApiRoute.elm +13 -13
  22. package/src/BackendTask/Env.elm +9 -8
  23. package/src/BackendTask/File.elm +49 -10
  24. package/src/BackendTask/Glob.elm +6 -6
  25. package/src/BackendTask/Http.elm +12 -12
  26. package/src/BackendTask/Port.elm +22 -14
  27. package/src/BackendTask.elm +8 -22
  28. package/src/{Exception.elm → FatalError.elm} +37 -31
  29. package/src/Form.elm +3 -3
  30. package/src/Internal/ApiRoute.elm +5 -5
  31. package/src/Pages/Generate.elm +1 -1
  32. package/src/Pages/Internal/FatalError.elm +5 -0
  33. package/src/Pages/Internal/Platform/Cli.elm +4 -4
  34. package/src/Pages/Internal/Platform/CompatibilityKey.elm +1 -1
  35. package/src/Pages/Internal/Platform/GeneratorApplication.elm +7 -7
  36. package/src/Pages/Internal/Platform/StaticResponses.elm +10 -9
  37. package/src/Pages/Internal/Script.elm +2 -2
  38. package/src/Pages/Manifest.elm +2 -2
  39. package/src/Pages/ProgramConfig.elm +7 -7
  40. package/src/Pages/Script.elm +4 -4
  41. package/src/Pages/SiteConfig.elm +2 -2
  42. package/src/Server/Request.elm +3 -3
@@ -15,7 +15,7 @@ all =
15
15
  import Server.Request as Request
16
16
 
17
17
  import BackendTask exposing (BackendTask)
18
- import Exception
18
+ import FatalError
19
19
  import RouteBuilder exposing (Page, StaticPayload, single)
20
20
  import Pages.PageUrl exposing (PageUrl)
21
21
  import Pages.Url
@@ -70,7 +70,7 @@ data =
70
70
  import Server.Request as Request
71
71
 
72
72
  import BackendTask exposing (BackendTask)
73
- import Exception
73
+ import FatalError
74
74
  import RouteBuilder exposing (Page, StaticPayload, single)
75
75
  import Pages.PageUrl exposing (PageUrl)
76
76
  import Pages.Url
@@ -100,7 +100,7 @@ route : StatelessRoute RouteParams Data ActionData
100
100
  route =
101
101
  single
102
102
  { head = head
103
- , data = BackendTask.fail (Exception.fromString "")
103
+ , data = BackendTask.fail (FatalError.fromString "")
104
104
  }
105
105
  |> RouteBuilder.buildNoState { view = view }
106
106
 
@@ -115,7 +115,7 @@ data =
115
115
  """module Route.Index exposing (Data, Model, Msg, route)
116
116
 
117
117
  import Server.Request as Request
118
- import Exception
118
+ import FatalError
119
119
  import BackendTask as DS
120
120
  import RouteBuilder exposing (Page, StaticPayload, single)
121
121
  import Pages.PageUrl exposing (PageUrl)
@@ -169,7 +169,7 @@ data =
169
169
  """module Route.Index exposing (Data, Model, Msg, route)
170
170
 
171
171
  import Server.Request as Request
172
- import Exception
172
+ import FatalError
173
173
  import BackendTask as DS
174
174
  import RouteBuilder exposing (Page, StaticPayload, single)
175
175
  import Pages.PageUrl exposing (PageUrl)
@@ -200,7 +200,7 @@ route : StatelessRoute RouteParams Data ActionData
200
200
  route =
201
201
  single
202
202
  { head = head
203
- , data = DS.fail (Exception.fromString "")
203
+ , data = DS.fail (FatalError.fromString "")
204
204
  }
205
205
  |> RouteBuilder.buildNoState { view = view }
206
206
 
@@ -217,7 +217,7 @@ data =
217
217
  import Server.Request as Request
218
218
 
219
219
  import BackendTask exposing (BackendTask)
220
- import Exception
220
+ import FatalError
221
221
  import RouteBuilder exposing (Page, StaticPayload)
222
222
  import Pages.PageUrl exposing (PageUrl)
223
223
  import Pages.Url
@@ -272,7 +272,7 @@ data =
272
272
  import Server.Request as Request
273
273
 
274
274
  import BackendTask exposing (BackendTask)
275
- import Exception
275
+ import FatalError
276
276
  import RouteBuilder exposing (Page, StaticPayload)
277
277
  import Pages.PageUrl exposing (PageUrl)
278
278
  import Pages.Url
@@ -301,7 +301,7 @@ type alias Data =
301
301
  route : StatelessRoute RouteParams Data ActionData
302
302
  route =
303
303
  RouteBuilder.preRender
304
- { data = \\_ -> BackendTask.fail (Exception.fromString "")
304
+ { data = \\_ -> BackendTask.fail (FatalError.fromString "")
305
305
  , head = head
306
306
  , pages = pages
307
307
  }
@@ -318,7 +318,7 @@ data =
318
318
  """module Route.Login exposing (Data, Model, Msg, route)
319
319
 
320
320
  import Server.Request as Request
321
- import Exception
321
+ import FatalError
322
322
 
323
323
  type alias Model =
324
324
  {}
@@ -355,7 +355,7 @@ route =
355
355
  """module Route.Login exposing (Data, Model, Msg, route)
356
356
 
357
357
  import Server.Request as Request
358
- import Exception
358
+ import FatalError
359
359
 
360
360
  type alias Model =
361
361
  {}
@@ -390,7 +390,7 @@ route =
390
390
  """module Route.Login exposing (Data, Model, Msg, route)
391
391
 
392
392
  import Server.Request as Request
393
- import Exception
393
+ import FatalError
394
394
 
395
395
  type alias Model =
396
396
  {}
@@ -419,7 +419,7 @@ route =
419
419
  """module Route.Login exposing (Data, Model, Msg, route)
420
420
 
421
421
  import Server.Request
422
- import Exception
422
+ import FatalError
423
423
 
424
424
  type alias Model =
425
425
  {}
@@ -456,7 +456,7 @@ route =
456
456
  """module Route.Login exposing (Data, Model, Msg, route)
457
457
 
458
458
  import Server.Request
459
- import Exception
459
+ import FatalError
460
460
 
461
461
  type alias Model =
462
462
  {}
@@ -491,7 +491,7 @@ route =
491
491
  """module Route.Login exposing (Data, Model, Msg, route)
492
492
 
493
493
  import Server.Request
494
- import Exception
494
+ import FatalError
495
495
 
496
496
  type alias Model =
497
497
  {}
@@ -520,7 +520,7 @@ route =
520
520
  """module Route.Login exposing (Data, Model, Msg, route)
521
521
 
522
522
  import Server.Request as Request
523
- import Exception
523
+ import FatalError
524
524
 
525
525
  type alias Model =
526
526
  {}
@@ -549,7 +549,7 @@ route =
549
549
  """module Route.Index exposing (Data, Model, Msg, route)
550
550
 
551
551
  import Server.Request as Request
552
- import Exception
552
+ import FatalError
553
553
 
554
554
  import BackendTask exposing (BackendTask)
555
555
  import RouteBuilder exposing (Page, StaticPayload)
@@ -581,7 +581,7 @@ route : StatelessRoute RouteParams Data ActionData
581
581
  route =
582
582
  RouteBuilder.single
583
583
  { head = head
584
- , data = BackendTask.fail (Exception.fromString "")
584
+ , data = BackendTask.fail (FatalError.fromString "")
585
585
  }
586
586
  |> RouteBuilder.buildNoState { view = view }
587
587
 
@@ -597,7 +597,7 @@ data =
597
597
  """module Shared exposing (Data, Model, Msg, template)
598
598
 
599
599
  import Server.Request as Request
600
- import Exception
600
+ import FatalError
601
601
 
602
602
  import Browser.Navigation
603
603
  import BackendTask
@@ -648,7 +648,7 @@ type alias Model =
648
648
  """module Shared exposing (Data, Model, Msg, template)
649
649
 
650
650
  import Server.Request as Request
651
- import Exception
651
+ import FatalError
652
652
 
653
653
  import Browser.Navigation
654
654
  import BackendTask
@@ -669,7 +669,7 @@ template =
669
669
  { init = init
670
670
  , update = update
671
671
  , view = view
672
- , data = BackendTask.fail (Exception.fromString "")
672
+ , data = BackendTask.fail (FatalError.fromString "")
673
673
  , subscriptions = subscriptions
674
674
  , onPageChange = Just OnPageChange
675
675
  }
@@ -75,7 +75,7 @@ console.elmlog = (str) => logs.push(str + "\n");
75
75
  const { Elm } = require("./Runner.elm.js");
76
76
 
77
77
  // Start the Elm app
78
- const flags = { initialSeed: 1951305281, fuzzRuns: 100, filter: null };
78
+ const flags = { initialSeed: 4260939212, fuzzRuns: 100, filter: null };
79
79
  const app = Elm.Runner.init({ flags: flags });
80
80
 
81
81
  // Record the timing at which we received the last "runTest" message
@@ -82,7 +82,7 @@ const verbosity = 0;
82
82
  // Create a long lived reporter worker
83
83
  const { Elm } = require("./Reporter.elm.js");
84
84
  const flags = {
85
- initialSeed: 1951305281,
85
+ initialSeed: 4260939212,
86
86
  fuzzRuns: 100,
87
87
  mode: "consoleNoColor",
88
88
  verbosity: verbosity,
@@ -89,7 +89,7 @@ import BackendTask exposing (BackendTask)
89
89
  import Dict exposing (Dict)
90
90
  import Effect exposing (Effect)
91
91
  import ErrorPage exposing (ErrorPage)
92
- import Exception exposing (Throwable)
92
+ import FatalError exposing (FatalError)
93
93
  import Head
94
94
  import Http
95
95
  import Json.Decode
@@ -109,9 +109,9 @@ import View exposing (View)
109
109
 
110
110
  {-| -}
111
111
  type alias StatefulRoute routeParams data action model msg =
112
- { data : Json.Decode.Value -> routeParams -> BackendTask Throwable (Server.Response.Response data ErrorPage)
113
- , action : Json.Decode.Value -> routeParams -> BackendTask Throwable (Server.Response.Response action ErrorPage)
114
- , staticRoutes : BackendTask Throwable (List routeParams)
112
+ { data : Json.Decode.Value -> routeParams -> BackendTask FatalError (Server.Response.Response data ErrorPage)
113
+ , action : Json.Decode.Value -> routeParams -> BackendTask FatalError (Server.Response.Response action ErrorPage)
114
+ , staticRoutes : BackendTask FatalError (List routeParams)
115
115
  , view :
116
116
  Maybe PageUrl
117
117
  -> Shared.Model
@@ -124,7 +124,7 @@ type alias StatefulRoute routeParams data action model msg =
124
124
  , init : Maybe PageUrl -> Shared.Model -> StaticPayload data action routeParams -> ( model, Effect msg )
125
125
  , update : PageUrl -> StaticPayload data action routeParams -> msg -> model -> Shared.Model -> ( model, Effect msg, Maybe Shared.Msg )
126
126
  , subscriptions : Maybe PageUrl -> routeParams -> Path -> model -> Shared.Model -> Sub msg
127
- , handleRoute : { moduleName : List String, routePattern : RoutePattern } -> (routeParams -> List ( String, String )) -> routeParams -> BackendTask Throwable (Maybe NotFoundReason)
127
+ , handleRoute : { moduleName : List String, routePattern : RoutePattern } -> (routeParams -> List ( String, String )) -> routeParams -> BackendTask FatalError (Maybe NotFoundReason)
128
128
  , kind : String
129
129
  , onAction : Maybe (action -> msg)
130
130
  }
@@ -154,9 +154,9 @@ type alias StaticPayload data action routeParams =
154
154
  {-| -}
155
155
  type Builder routeParams data action
156
156
  = WithData
157
- { data : Json.Decode.Value -> routeParams -> BackendTask Throwable (Server.Response.Response data ErrorPage)
158
- , action : Json.Decode.Value -> routeParams -> BackendTask Throwable (Server.Response.Response action ErrorPage)
159
- , staticRoutes : BackendTask Throwable (List routeParams)
157
+ { data : Json.Decode.Value -> routeParams -> BackendTask FatalError (Server.Response.Response data ErrorPage)
158
+ , action : Json.Decode.Value -> routeParams -> BackendTask FatalError (Server.Response.Response action ErrorPage)
159
+ , staticRoutes : BackendTask FatalError (List routeParams)
160
160
  , head :
161
161
  StaticPayload data action routeParams
162
162
  -> List Head.Tag
@@ -165,7 +165,7 @@ type Builder routeParams data action
165
165
  { moduleName : List String, routePattern : RoutePattern }
166
166
  -> (routeParams -> List ( String, String ))
167
167
  -> routeParams
168
- -> BackendTask Throwable (Maybe NotFoundReason)
168
+ -> BackendTask FatalError (Maybe NotFoundReason)
169
169
  , kind : String
170
170
  }
171
171
 
@@ -292,14 +292,14 @@ buildWithSharedState config builderState =
292
292
 
293
293
  {-| -}
294
294
  single :
295
- { data : BackendTask Throwable data
295
+ { data : BackendTask FatalError data
296
296
  , head : StaticPayload data action {} -> List Head.Tag
297
297
  }
298
298
  -> Builder {} data action
299
299
  single { data, head } =
300
300
  WithData
301
301
  { data = \_ _ -> data |> BackendTask.map Server.Response.render
302
- , action = \_ _ -> BackendTask.fail (Exception.fromString "Internal Error - actions should never be called for statically generated pages.")
302
+ , action = \_ _ -> BackendTask.fail (FatalError.fromString "Internal Error - actions should never be called for statically generated pages.")
303
303
  , staticRoutes = BackendTask.succeed [ {} ]
304
304
  , head = head
305
305
  , serverless = False
@@ -310,15 +310,15 @@ single { data, head } =
310
310
 
311
311
  {-| -}
312
312
  preRender :
313
- { data : routeParams -> BackendTask Throwable data
314
- , pages : BackendTask Throwable (List routeParams)
313
+ { data : routeParams -> BackendTask FatalError data
314
+ , pages : BackendTask FatalError (List routeParams)
315
315
  , head : StaticPayload data action routeParams -> List Head.Tag
316
316
  }
317
317
  -> Builder routeParams data action
318
318
  preRender { data, head, pages } =
319
319
  WithData
320
320
  { data = \_ -> data >> BackendTask.map Server.Response.render
321
- , action = \_ _ -> BackendTask.fail (Exception.fromString "Internal Error - actions should never be called for statically generated pages.")
321
+ , action = \_ _ -> BackendTask.fail (FatalError.fromString "Internal Error - actions should never be called for statically generated pages.")
322
322
  , staticRoutes = pages
323
323
  , head = head
324
324
  , serverless = False
@@ -348,15 +348,15 @@ preRender { data, head, pages } =
348
348
 
349
349
  {-| -}
350
350
  preRenderWithFallback :
351
- { data : routeParams -> BackendTask Throwable (Server.Response.Response data ErrorPage)
352
- , pages : BackendTask Throwable (List routeParams)
351
+ { data : routeParams -> BackendTask FatalError (Server.Response.Response data ErrorPage)
352
+ , pages : BackendTask FatalError (List routeParams)
353
353
  , head : StaticPayload data action routeParams -> List Head.Tag
354
354
  }
355
355
  -> Builder routeParams data action
356
356
  preRenderWithFallback { data, head, pages } =
357
357
  WithData
358
358
  { data = \_ -> data
359
- , action = \_ _ -> BackendTask.fail (Exception.fromString "Internal Error - actions should never be called for statically generated pages.")
359
+ , action = \_ _ -> BackendTask.fail (FatalError.fromString "Internal Error - actions should never be called for statically generated pages.")
360
360
  , staticRoutes = pages
361
361
  , head = head
362
362
  , serverless = False
@@ -369,8 +369,8 @@ preRenderWithFallback { data, head, pages } =
369
369
 
370
370
  {-| -}
371
371
  serverRender :
372
- { data : routeParams -> Server.Request.Parser (BackendTask Throwable (Server.Response.Response data ErrorPage))
373
- , action : routeParams -> Server.Request.Parser (BackendTask Throwable (Server.Response.Response action ErrorPage))
372
+ { data : routeParams -> Server.Request.Parser (BackendTask FatalError (Server.Response.Response data ErrorPage))
373
+ , action : routeParams -> Server.Request.Parser (BackendTask FatalError (Server.Response.Response action ErrorPage))
374
374
  , head : StaticPayload data action routeParams -> List Head.Tag
375
375
  }
376
376
  -> Builder routeParams data action
@@ -386,7 +386,7 @@ serverRender { data, action, head } =
386
386
  |> Result.mapError Json.Decode.errorToString
387
387
  |> BackendTask.fromResult
388
388
  -- TODO include title and better error context and formatting
389
- |> BackendTask.onError (\error -> BackendTask.fail (Exception.fromString error))
389
+ |> BackendTask.onError (\error -> BackendTask.fail (FatalError.fromString error))
390
390
  )
391
391
  )
392
392
  |> BackendTask.andThen
@@ -397,7 +397,7 @@ serverRender { data, action, head } =
397
397
 
398
398
  Err error ->
399
399
  Server.Request.errorsToString error
400
- |> Exception.fromString
400
+ |> FatalError.fromString
401
401
  |> BackendTask.fail
402
402
  )
403
403
  , action =
@@ -410,7 +410,7 @@ serverRender { data, action, head } =
410
410
  |> Result.mapError Json.Decode.errorToString
411
411
  |> BackendTask.fromResult
412
412
  -- TODO include title and better error context and formatting
413
- |> BackendTask.onError (\error -> BackendTask.fail (Exception.fromString error))
413
+ |> BackendTask.onError (\error -> BackendTask.fail (FatalError.fromString error))
414
414
  )
415
415
  )
416
416
  |> BackendTask.andThen
@@ -421,7 +421,7 @@ serverRender { data, action, head } =
421
421
 
422
422
  Err error ->
423
423
  Server.Request.errorsToString error
424
- |> Exception.fromString
424
+ |> FatalError.fromString
425
425
  |> BackendTask.fail
426
426
  )
427
427
  , staticRoutes = BackendTask.succeed []
@@ -2,7 +2,7 @@ module SharedTemplate exposing (SharedTemplate)
2
2
 
3
3
  import BackendTask
4
4
  import Effect exposing (Effect)
5
- import Exception exposing (Throwable)
5
+ import FatalError exposing (FatalError)
6
6
  import Html exposing (Html)
7
7
  import Pages.Flags exposing (Flags)
8
8
  import Pages.PageUrl exposing (PageUrl)
@@ -36,7 +36,7 @@ type alias SharedTemplate msg sharedModel sharedData mappedMsg =
36
36
  -> (msg -> mappedMsg)
37
37
  -> View mappedMsg
38
38
  -> { body : List (Html mappedMsg), title : String }
39
- , data : BackendTask.BackendTask Throwable sharedData
39
+ , data : BackendTask.BackendTask FatalError sharedData
40
40
  , subscriptions : Path -> sharedModel -> Sub msg
41
41
  , onPageChange :
42
42
  Maybe
@@ -1,11 +1,11 @@
1
1
  module 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
  }
@@ -270,7 +270,7 @@ function generatorWrapperFile(moduleName) {
270
270
 
271
271
  import Bytes
272
272
  import BackendTask exposing (BackendTask)
273
- import Exception
273
+ import FatalError
274
274
  import Cli.Program as Program
275
275
  import Json.Decode as Decode
276
276
  import Json.Encode as Encode
@@ -278,7 +278,7 @@ import Pages.Internal.Platform.GeneratorApplication
278
278
  import ${moduleName}
279
279
 
280
280
 
281
- main : Program.StatefulProgram Pages.Internal.Platform.GeneratorApplication.Model Pages.Internal.Platform.GeneratorApplication.Msg (BackendTask Exception.Throwable ()) Pages.Internal.Platform.GeneratorApplication.Flags
281
+ main : Program.StatefulProgram Pages.Internal.Platform.GeneratorApplication.Model Pages.Internal.Platform.GeneratorApplication.Msg (BackendTask FatalError.FatalError ()) Pages.Internal.Platform.GeneratorApplication.Flags
282
282
  main =
283
283
  Pages.Internal.Platform.GeneratorApplication.app
284
284
  { data = ${moduleName}.run
@@ -1 +1 @@
1
- module.exports = { compatibilityKey: 5 };
1
+ module.exports = { compatibilityKey: 6 };
@@ -642,11 +642,11 @@ function flushIfDone(app) {
642
642
 
643
643
  function flushQueue(app) {
644
644
  // TODO - could the case where flush is called with size 0 be avoided on the Elm side?
645
- if (pendingBackendTaskResponses.size > 0) {
646
- // console.log("@@@ FLUSHING", pendingBackendTaskResponses.size);
647
- app.ports.gotBatchSub.send(Object.fromEntries(pendingBackendTaskResponses));
648
- pendingBackendTaskResponses = new Map();
649
- }
645
+ // if (pendingBackendTaskResponses.size > 0) {
646
+ // console.log("@@@ FLUSHING", pendingBackendTaskResponses.size);
647
+ app.ports.gotBatchSub.send(Object.fromEntries(pendingBackendTaskResponses));
648
+ pendingBackendTaskResponses = new Map();
649
+ // }
650
650
  }
651
651
 
652
652
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elm-pages",
3
- "version": "3.0.0-beta.15",
3
+ "version": "3.0.0-beta.16",
4
4
  "homepage": "https://elm-pages.com",
5
5
  "moduleResolution": "node",
6
6
  "description": "Type-safe static sites, written in pure elm with your own custom elm-markup syntax.",
package/src/ApiRoute.elm CHANGED
@@ -173,7 +173,7 @@ You define your ApiRoute's in `app/Api.elm`. Here's a simple example:
173
173
  -}
174
174
 
175
175
  import BackendTask exposing (BackendTask)
176
- import Exception exposing (Throwable)
176
+ import FatalError exposing (FatalError)
177
177
  import Head
178
178
  import Internal.ApiRoute exposing (ApiRoute(..), ApiRouteBuilder(..))
179
179
  import Json.Decode as Decode
@@ -192,14 +192,14 @@ type alias ApiRoute response =
192
192
  {-| Same as [`preRender`](#preRender), but for an ApiRoute that has no dynamic segments. This is just a bit simpler because
193
193
  since there are no dynamic segments, you don't need to provide a BackendTask with the list of dynamic segments to pre-render because there is only a single possible route.
194
194
  -}
195
- single : ApiRouteBuilder (BackendTask Throwable String) (List String) -> ApiRoute Response
195
+ single : ApiRouteBuilder (BackendTask FatalError String) (List String) -> ApiRoute Response
196
196
  single handler =
197
197
  handler
198
198
  |> preRender (\constructor -> BackendTask.succeed [ constructor ])
199
199
 
200
200
 
201
201
  {-| -}
202
- serverRender : ApiRouteBuilder (Server.Request.Parser (BackendTask Throwable (Server.Response.Response Never Never))) constructor -> ApiRoute Response
202
+ serverRender : ApiRouteBuilder (Server.Request.Parser (BackendTask FatalError (Server.Response.Response Never Never))) constructor -> ApiRoute Response
203
203
  serverRender ((ApiRouteBuilder patterns pattern _ _ _) as fullHandler) =
204
204
  ApiRoute
205
205
  { regex = Regex.fromString ("^" ++ pattern ++ "$") |> Maybe.withDefault Regex.never
@@ -218,7 +218,7 @@ serverRender ((ApiRouteBuilder patterns pattern _ _ _) as fullHandler) =
218
218
  |> BackendTask.onError
219
219
  (\stringError ->
220
220
  -- TODO make error with title and better context/formatting
221
- Exception.fromString stringError |> BackendTask.fail
221
+ FatalError.fromString stringError |> BackendTask.fail
222
222
  )
223
223
  |> BackendTask.andThen
224
224
  (\rendered ->
@@ -260,10 +260,10 @@ serverRender ((ApiRouteBuilder patterns pattern _ _ _) as fullHandler) =
260
260
 
261
261
 
262
262
  {-| -}
263
- preRenderWithFallback : (constructor -> BackendTask Throwable (List (List String))) -> ApiRouteBuilder (BackendTask Throwable (Server.Response.Response Never Never)) constructor -> ApiRoute Response
263
+ preRenderWithFallback : (constructor -> BackendTask FatalError (List (List String))) -> ApiRouteBuilder (BackendTask FatalError (Server.Response.Response Never Never)) constructor -> ApiRoute Response
264
264
  preRenderWithFallback buildUrls ((ApiRouteBuilder patterns pattern _ toString constructor) as fullHandler) =
265
265
  let
266
- buildTimeRoutes__ : BackendTask Throwable (List String)
266
+ buildTimeRoutes__ : BackendTask FatalError (List String)
267
267
  buildTimeRoutes__ =
268
268
  buildUrls (constructor [])
269
269
  |> BackendTask.map (List.map toString)
@@ -302,15 +302,15 @@ encodeStaticFileBody fileBody =
302
302
 
303
303
 
304
304
  {-| -}
305
- preRender : (constructor -> BackendTask Throwable (List (List String))) -> ApiRouteBuilder (BackendTask Throwable String) constructor -> ApiRoute Response
305
+ preRender : (constructor -> BackendTask FatalError (List (List String))) -> ApiRouteBuilder (BackendTask FatalError String) constructor -> ApiRoute Response
306
306
  preRender buildUrls ((ApiRouteBuilder patterns pattern _ toString constructor) as fullHandler) =
307
307
  let
308
- buildTimeRoutes__ : BackendTask Throwable (List String)
308
+ buildTimeRoutes__ : BackendTask FatalError (List String)
309
309
  buildTimeRoutes__ =
310
310
  buildUrls (constructor [])
311
311
  |> BackendTask.map (List.map toString)
312
312
 
313
- preBuiltMatches : BackendTask Throwable (List (List String))
313
+ preBuiltMatches : BackendTask FatalError (List (List String))
314
314
  preBuiltMatches =
315
315
  buildUrls (constructor [])
316
316
  in
@@ -323,7 +323,7 @@ preRender buildUrls ((ApiRouteBuilder patterns pattern _ toString constructor) a
323
323
  matches =
324
324
  Internal.ApiRoute.pathToMatches path fullHandler
325
325
 
326
- routeFound : BackendTask Throwable Bool
326
+ routeFound : BackendTask FatalError Bool
327
327
  routeFound =
328
328
  preBuiltMatches
329
329
  |> BackendTask.map (List.member matches)
@@ -431,19 +431,19 @@ capture (ApiRouteBuilder patterns pattern previousHandler toString constructor)
431
431
 
432
432
  {-| For internal use by generated code. Not so useful in user-land.
433
433
  -}
434
- getBuildTimeRoutes : ApiRoute response -> BackendTask Throwable (List String)
434
+ getBuildTimeRoutes : ApiRoute response -> BackendTask FatalError (List String)
435
435
  getBuildTimeRoutes (ApiRoute handler) =
436
436
  handler.buildTimeRoutes
437
437
 
438
438
 
439
439
  {-| Include head tags on every page's HTML.
440
440
  -}
441
- withGlobalHeadTags : BackendTask Throwable (List Head.Tag) -> ApiRoute response -> ApiRoute response
441
+ withGlobalHeadTags : BackendTask FatalError (List Head.Tag) -> ApiRoute response -> ApiRoute response
442
442
  withGlobalHeadTags globalHeadTags (ApiRoute handler) =
443
443
  ApiRoute { handler | globalHeadTags = Just globalHeadTags }
444
444
 
445
445
 
446
446
  {-| -}
447
- getGlobalHeadTagsBackendTask : ApiRoute response -> Maybe (BackendTask Throwable (List Head.Tag))
447
+ getGlobalHeadTagsBackendTask : ApiRoute response -> Maybe (BackendTask FatalError (List Head.Tag))
448
448
  getGlobalHeadTagsBackendTask (ApiRoute handler) =
449
449
  handler.globalHeadTags
@@ -8,23 +8,23 @@ down into the final `Data` value, it won't end up in the client!
8
8
 
9
9
  import BackendTask exposing (BackendTask)
10
10
  import BackendTask.Env
11
- import Exception exposing (Throwable)
11
+ import FatalError exposing (FatalError)
12
12
 
13
13
  type alias EnvVariables =
14
14
  { sendGridKey : String
15
15
  , siteUrl : String
16
16
  }
17
17
 
18
- sendEmail : Email -> BackendTask Throwable ()
18
+ sendEmail : Email -> BackendTask FatalError ()
19
19
  sendEmail email =
20
20
  BackendTask.map2 EnvVariables
21
- (BackendTask.Env.expect "SEND_GRID_KEY" |> BackendTask.throw)
21
+ (BackendTask.Env.expect "SEND_GRID_KEY" |> BackendTask.allowFatal)
22
22
  (BackendTask.Env.get "BASE_URL"
23
23
  |> BackendTask.map (Maybe.withDefault "http://localhost:1234")
24
24
  )
25
25
  |> BackendTask.andThen (sendEmailBackendTask email)
26
26
 
27
- sendEmailBackendTask : Email -> EnvVariables -> BackendTask Throwable ()
27
+ sendEmailBackendTask : Email -> EnvVariables -> BackendTask FatalError ()
28
28
  sendEmailBackendTask email envVariables =
29
29
  Debug.todo "Not defined here"
30
30
 
@@ -40,7 +40,7 @@ down into the final `Data` value, it won't end up in the client!
40
40
  import BackendTask exposing (BackendTask)
41
41
  import BackendTask.Http
42
42
  import BackendTask.Internal.Request
43
- import Exception exposing (Exception)
43
+ import FatalError exposing (FatalError)
44
44
  import Json.Decode as Decode
45
45
  import Json.Encode as Encode
46
46
  import TerminalText
@@ -65,9 +65,9 @@ get envVariableName =
65
65
  }
66
66
 
67
67
 
68
- {-| Get an environment variable, or a BackendTask Exception if there is no environment variable matching that name.
68
+ {-| Get an environment variable, or a BackendTask FatalError if there is no environment variable matching that name.
69
69
  -}
70
- expect : String -> BackendTask (Exception Error) String
70
+ expect : String -> BackendTask { fatal : FatalError, recoverable : Error } String
71
71
  expect envVariableName =
72
72
  envVariableName
73
73
  |> get
@@ -75,7 +75,7 @@ expect envVariableName =
75
75
  (\maybeValue ->
76
76
  maybeValue
77
77
  |> Result.fromMaybe
78
- (Exception.Exception (MissingEnvVariable envVariableName)
78
+ (FatalError.recoverable
79
79
  { title = "Missing Env Variable"
80
80
  , body =
81
81
  [ TerminalText.text "BackendTask.Env.expect was expecting a variable `"
@@ -84,6 +84,7 @@ expect envVariableName =
84
84
  ]
85
85
  |> TerminalText.toString
86
86
  }
87
+ (MissingEnvVariable envVariableName)
87
88
  )
88
89
  |> BackendTask.fromResult
89
90
  )