Reduce oneOf decoder error noise for error case in BackendTask.Custom failures.

This commit is contained in:
Dillon Kearns 2023-02-13 19:00:56 -08:00
parent 26670d4283
commit a444c5af2c

View File

@ -110,10 +110,15 @@ run portName input decoder =
] ]
|> BackendTask.Http.jsonBody |> BackendTask.Http.jsonBody
, expect = , expect =
Decode.oneOf Decode.field "elm-pages-internal-error" Decode.string
[ Decode.field "elm-pages-internal-error" Decode.string |> Decode.maybe
|> Decode.andThen |> Decode.andThen
(\errorKind -> (\maybeInternalErrorCode ->
case maybeInternalErrorCode of
Just errorKind ->
--Decode.field "elm-pages-internal-error" Decode.string
-- |> Decode.andThen
(--\errorKind ->
if errorKind == "CustomBackendTaskNotDefined" then if errorKind == "CustomBackendTaskNotDefined" then
FatalError.recoverable FatalError.recoverable
{ title = "Custom BackendTask Error" { title = "Custom BackendTask Error"
@ -225,8 +230,10 @@ run portName input decoder =
|> Decode.succeed |> Decode.succeed
) )
|> Decode.map Err |> Decode.map Err
, decoder |> Decode.map Ok
] Nothing ->
decoder |> Decode.map Ok
)
|> BackendTask.Http.expectJson |> BackendTask.Http.expectJson
} }
|> BackendTask.andThen BackendTask.fromResult |> BackendTask.andThen BackendTask.fromResult