Skip to content

Commit

Permalink
Include title in BuildError type.
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonkearns committed Dec 7, 2019
1 parent 658798e commit fc6f0e3
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/BuildError.elm
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ import TerminalText


type alias BuildError =
{ message : List TerminalText.Text
{ title : String
, message : List TerminalText.Text
}
3 changes: 2 additions & 1 deletion src/Pages/ContentCache.elm
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ createErrors path decodeError =

createBuildError : List String -> String -> BuildError
createBuildError path decodeError =
{ message =
{ title = "Metadata Decode Error"
, message =
[ Terminal.text "I ran into a problem when parsing the metadata for the page with this path: "
, Terminal.text ("/" ++ (path |> String.join "/"))
, Terminal.text "\n\n"
Expand Down
10 changes: 7 additions & 3 deletions src/Pages/Internal/Platform/Cli.elm
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,10 @@ init toModel contentCache siteMetadata config flags =
updateAndSendPortIfDone
(Model Dict.empty
SecretsDict.masked
[ InternalError <| { message = [ Terminal.text <| "Failed to parse flags: " ++ Decode.errorToString error ] }
[ InternalError <|
{ title = "Internal Error"
, message = [ Terminal.text <| "Failed to parse flags: " ++ Decode.errorToString error ]
}
]
Dict.empty
Dev
Expand Down Expand Up @@ -459,7 +462,8 @@ update siteMetadata config msg model =
| errors =
model.errors
++ [ FailedStaticHttpRequestError
{ message =
{ title = "Static HTTP Error"
, message =
[ Terminal.text "I got an error making an HTTP request to this URL: "

-- TODO include HTTP method, headers, and body
Expand All @@ -480,7 +484,7 @@ update siteMetadata config msg model =
Terminal.text "Network error"

Http.BadBody string ->
Terminal.text "Network error"
Terminal.text "Unable to parse HTTP response body"
]
}
]
Expand Down
3 changes: 2 additions & 1 deletion src/Pages/StaticHttpRequest.elm
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ urls request =

toBuildError : String -> Error -> BuildError
toBuildError path error =
{ message =
{ title = "Static HTTP Error"
, message =
[ Terminal.text path
, Terminal.text "\n\n"
, Terminal.text (errorToString error)
Expand Down
3 changes: 2 additions & 1 deletion src/Secrets.elm
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ buildError secretName secretsDict =
availableEnvironmentVariables =
SecretsDict.available secretsDict
in
{ message =
{ title = "Missing Secret"
, message =
[ Terminal.text "I expected to find this Secret in your environment variables but didn't find a match:\n\nSecrets.get \""
, Terminal.text secretName
, Terminal.text "\"\n "
Expand Down

0 comments on commit fc6f0e3

Please sign in to comment.