mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-28 06:05:31 +03:00
Inline error to string function for static http requests.
This commit is contained in:
parent
39d9f84783
commit
79142c7be1
@ -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
|
||||
|
@ -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
|
||||
|
@ -490,7 +490,7 @@ all =
|
||||
"toJsPort"
|
||||
(Codec.decoder Main.toJsCodec)
|
||||
(expectErrorsPort
|
||||
"""-- STATIC HTTP ERROR ----------------------------------------------------- elm-pages
|
||||
"""-- STATIC HTTP DECODING ERROR ----------------------------------------------------- elm-pages
|
||||
|
||||
/elm-pages
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user