Skip to content

Commit

Permalink
Add data for whether build failures are fatal and continue dev server…
Browse files Browse the repository at this point in the history
… if they are not.
  • Loading branch information
dillonkearns committed Jan 28, 2020
1 parent c714597 commit d22521a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/BuildError.elm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import TerminalText as Terminal
type alias BuildError =
{ title : String
, message : List Terminal.Text
, fatal : Bool
}


Expand Down
1 change: 1 addition & 0 deletions src/Pages/ContentCache.elm
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ createBuildError path decodeError =
, Terminal.text "\n\n"
, Terminal.text decodeError
]
, fatal = False
}


Expand Down
35 changes: 23 additions & 12 deletions src/Pages/Internal/Platform/Cli.elm
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ init toModel contentCache siteMetadata config flags =
SecretsDict.masked
[ { title = "Internal Error"
, message = [ Terminal.text <| "Failed to parse flags: " ++ Decode.errorToString error ]
, fatal = True
}
]
Dict.empty
Expand Down Expand Up @@ -478,6 +479,7 @@ update siteMetadata config msg model =
Http.BadBody string ->
Terminal.text "Unable to parse HTTP response body"
]
, fatal = True
}
]
}
Expand Down Expand Up @@ -840,6 +842,7 @@ sendStaticResponsesIfDone config siteMetadata mode secrets allRawResponses error
[ Terminal.text "I encountered an Err from your generateFiles function. Message:\n"
, Terminal.text <| "Error: " ++ error
]
, fatal = True
}
)

Expand All @@ -848,21 +851,29 @@ sendStaticResponsesIfDone config siteMetadata mode secrets allRawResponses error
errors ++ failedRequests ++ generatedFileErrors
in
( updatedAllRawResponses
, SendJsData <|
if List.isEmpty failedRequests then
Success
(ToJsSuccessPayload
(encodeStaticResponses mode staticResponses)
config.manifest
generatedOkayFiles
(List.map BuildError.errorToString allErrors)
)

else
Errors <| BuildError.errorsToString allErrors
, toJsPayload
(encodeStaticResponses mode staticResponses)
config.manifest
generatedOkayFiles
allErrors
)


toJsPayload encodedStatic manifest generated allErrors =
SendJsData <|
if allErrors |> List.filter .fatal |> List.isEmpty then
Success
(ToJsSuccessPayload
encodedStatic
manifest
generated
(List.map BuildError.errorToString allErrors)
)

else
Errors <| BuildError.errorsToString allErrors


encodeStaticResponses : Mode -> StaticResponses -> Dict String (Dict String String)
encodeStaticResponses mode staticResponses =
staticResponses
Expand Down
2 changes: 2 additions & 0 deletions src/Pages/StaticHttpRequest.elm
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ toBuildError path error =
, Terminal.text "\n\n"
, Terminal.text missingKey
]
, fatal = True
}

DecoderError decodeErrorMessage ->
Expand All @@ -61,6 +62,7 @@ toBuildError path error =
, Terminal.text "\n\n"
, Terminal.text decodeErrorMessage
]
, fatal = True
}


Expand Down
1 change: 1 addition & 0 deletions src/Secrets.elm
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ buildError secretName secretsDict =
, Terminal.text " should be "
, Terminal.green <| Terminal.text (sortMatches secretName availableEnvironmentVariables |> List.head |> Maybe.withDefault "")
]
, fatal = True
}


Expand Down

0 comments on commit d22521a

Please sign in to comment.