diff --git a/src/Pages/Internal/Platform/Cli.elm b/src/Pages/Internal/Platform/Cli.elm index 1e20d6a6..e81bdb95 100644 --- a/src/Pages/Internal/Platform/Cli.elm +++ b/src/Pages/Internal/Platform/Cli.elm @@ -623,6 +623,16 @@ printKeys message dict = dict +isJust : Maybe a -> Bool +isJust maybeValue = + case maybeValue of + Just _ -> + True + + Nothing -> + False + + sendStaticResponsesIfDone : Mode -> SecretsDict -> Dict String (Maybe String) -> List BuildError -> StaticResponses -> Manifest.Config pathKey -> ( Dict String (Maybe String), Effect pathKey ) sendStaticResponsesIfDone mode secrets allRawResponses errors staticResponses manifest = let @@ -646,8 +656,7 @@ sendStaticResponsesIfDone mode secrets allRawResponses errors staticResponses ma hasPermanentError = StaticHttpRequest.permanentError request usableRawResponses - |> Maybe.map (\_ -> True) - |> Maybe.withDefault False + |> isJust hasPermanentHttpError = not <| List.isEmpty errors diff --git a/src/Pages/StaticHttpRequest.elm b/src/Pages/StaticHttpRequest.elm index 5817c9f9..9d1ca391 100644 --- a/src/Pages/StaticHttpRequest.elm +++ b/src/Pages/StaticHttpRequest.elm @@ -1,4 +1,4 @@ -module Pages.StaticHttpRequest exposing (Error(..), Request(..), errorToString, permanentError, resolve, resolveUrls, strippedResponses, toBuildError, urls) +module Pages.StaticHttpRequest exposing (Error(..), Request(..), permanentError, resolve, resolveUrls, strippedResponses, toBuildError, urls) import BuildError exposing (BuildError) import Dict exposing (Dict) @@ -26,16 +26,6 @@ strippedResponses request rawResponses = rawResponses -errorToString : Error -> String -errorToString error = - case error of - MissingHttpResponse string -> - string - - DecoderError string -> - string - - type Error = MissingHttpResponse String | DecoderError String @@ -57,13 +47,24 @@ urls request = toBuildError : String -> Error -> BuildError toBuildError path error = - { title = "Static HTTP Error" - , message = - [ Terminal.text path - , Terminal.text "\n\n" - , Terminal.text (errorToString error) - ] - } + case error of + MissingHttpResponse missingKey -> + { title = "Missing Http Response" + , message = + [ Terminal.text path + , Terminal.text "\n\n" + , Terminal.text missingKey + ] + } + + DecoderError decodeErrorMessage -> + { title = "Static Http Decoding Error" + , message = + [ Terminal.text path + , Terminal.text "\n\n" + , Terminal.text decodeErrorMessage + ] + } permanentError : Request value -> Dict String String -> Maybe Error diff --git a/tests/StaticHttpRequestsTests.elm b/tests/StaticHttpRequestsTests.elm index 29813005..239d2270 100644 --- a/tests/StaticHttpRequestsTests.elm +++ b/tests/StaticHttpRequestsTests.elm @@ -490,7 +490,7 @@ all = "toJsPort" (Codec.decoder Main.toJsCodec) (expectErrorsPort - """-- STATIC HTTP ERROR ----------------------------------------------------- elm-pages + """-- STATIC HTTP DECODING ERROR ----------------------------------------------------- elm-pages /elm-pages