mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-28 06:05:31 +03:00
Change generateFiles to return Results so users can make it fail explicitly instead of squelching errors.
This commit is contained in:
parent
194aa06dfb
commit
c79d736844
@ -81,12 +81,14 @@ generateFiles :
|
||||
}
|
||||
->
|
||||
List
|
||||
{ path : List String
|
||||
, content : String
|
||||
}
|
||||
(Result String
|
||||
{ path : List String
|
||||
, content : String
|
||||
}
|
||||
)
|
||||
generateFiles siteMetadata =
|
||||
[ Feed.fileToGenerate { siteTagline = siteTagline, siteUrl = canonicalSiteUrl } siteMetadata
|
||||
, MySitemap.build { siteUrl = canonicalSiteUrl } siteMetadata
|
||||
[ Feed.fileToGenerate { siteTagline = siteTagline, siteUrl = canonicalSiteUrl } siteMetadata |> Ok
|
||||
, MySitemap.build { siteUrl = canonicalSiteUrl } siteMetadata |> Ok
|
||||
]
|
||||
|
||||
|
||||
|
@ -541,9 +541,11 @@ application :
|
||||
}
|
||||
->
|
||||
List
|
||||
{ path : List String
|
||||
, content : String
|
||||
}
|
||||
(Result String
|
||||
{ path : List String
|
||||
, content : String
|
||||
}
|
||||
)
|
||||
, canonicalSiteUrl : String
|
||||
, pathKey : pathKey
|
||||
, onPageChange : PagePath pathKey -> userMsg
|
||||
@ -632,9 +634,11 @@ cliApplication :
|
||||
}
|
||||
->
|
||||
List
|
||||
{ path : List String
|
||||
, content : String
|
||||
}
|
||||
(Result String
|
||||
{ path : List String
|
||||
, content : String
|
||||
}
|
||||
)
|
||||
, canonicalSiteUrl : String
|
||||
, pathKey : pathKey
|
||||
, onPageChange : PagePath pathKey -> userMsg
|
||||
|
@ -177,9 +177,11 @@ type alias Config pathKey userMsg userModel metadata view =
|
||||
}
|
||||
->
|
||||
List
|
||||
{ path : List String
|
||||
, content : String
|
||||
}
|
||||
(Result String
|
||||
{ path : List String
|
||||
, content : String
|
||||
}
|
||||
)
|
||||
, canonicalSiteUrl : String
|
||||
, pathKey : pathKey
|
||||
, onPageChange : PagePath pathKey -> userMsg
|
||||
@ -797,19 +799,56 @@ sendStaticResponsesIfDone config siteMetadata mode secrets allRawResponses error
|
||||
}
|
||||
)
|
||||
|> config.generateFiles
|
||||
|
||||
generatedOkayFiles =
|
||||
generatedFiles
|
||||
|> List.filterMap
|
||||
(\result ->
|
||||
case result of
|
||||
Ok ok ->
|
||||
Just ok
|
||||
|
||||
_ ->
|
||||
Nothing
|
||||
)
|
||||
|
||||
generatedFileErrors =
|
||||
generatedFiles
|
||||
|> List.filterMap
|
||||
(\result ->
|
||||
case result of
|
||||
Ok ok ->
|
||||
Nothing
|
||||
|
||||
Err error ->
|
||||
Just
|
||||
{ title = "Generate Files Error"
|
||||
, message =
|
||||
[ Terminal.text "I encountered an Err in the generateFiles for the path TODO."
|
||||
, Terminal.text <| "\nError: " ++ error
|
||||
]
|
||||
|
||||
-- List Terminal.Text
|
||||
}
|
||||
--Just error
|
||||
)
|
||||
|
||||
allErrors : List BuildError
|
||||
allErrors =
|
||||
errors ++ failedRequests ++ generatedFileErrors
|
||||
in
|
||||
( updatedAllRawResponses
|
||||
, SendJsData
|
||||
(if List.isEmpty errors && List.isEmpty failedRequests then
|
||||
(if List.isEmpty allErrors then
|
||||
Success
|
||||
(ToJsSuccessPayload
|
||||
(encodeStaticResponses mode staticResponses)
|
||||
config.manifest
|
||||
generatedFiles
|
||||
generatedOkayFiles
|
||||
)
|
||||
|
||||
else
|
||||
Errors <| BuildError.errorsToString (failedRequests ++ errors)
|
||||
Errors <| BuildError.errorsToString allErrors
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -85,9 +85,11 @@ application :
|
||||
}
|
||||
->
|
||||
List
|
||||
{ path : List String
|
||||
, content : String
|
||||
}
|
||||
(Result String
|
||||
{ path : List String
|
||||
, content : String
|
||||
}
|
||||
)
|
||||
, onPageChange : PagePath pathKey -> userMsg
|
||||
, canonicalSiteUrl : String
|
||||
, internals : Pages.Internal.Internal pathKey
|
||||
|
@ -564,9 +564,17 @@ start pages =
|
||||
Debug.todo "Couldn't find page"
|
||||
}
|
||||
in
|
||||
{-
|
||||
(Model -> model)
|
||||
-> ContentCache.ContentCache metadata view
|
||||
-> Result (List BuildError) (List ( PagePath pathKey, metadata ))
|
||||
-> Config pathKey userMsg userModel metadata view
|
||||
-> Decode.Value
|
||||
-> ( model, Effect pathKey )
|
||||
-}
|
||||
ProgramTest.createDocument
|
||||
{ init = Main.init identity contentCache siteMetadata config
|
||||
, update = Main.update config
|
||||
, update = Main.update siteMetadata config
|
||||
, view = \_ -> { title = "", body = [] }
|
||||
}
|
||||
|> ProgramTest.withSimulatedEffects simulateEffects
|
||||
|
Loading…
Reference in New Issue
Block a user