From 499390aeaea488d115dfbf68649682adfa9d09eb Mon Sep 17 00:00:00 2001 From: Dillon Kearns Date: Thu, 29 Dec 2022 14:14:08 -0700 Subject: [PATCH] Fix errors. --- src/DataSource/Http.elm | 15 ++++++++++++++- tests/StaticHttpRequestsTests.elm | 6 +++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/DataSource/Http.elm b/src/DataSource/Http.elm index 1ef4be1b..01557f21 100644 --- a/src/DataSource/Http.elm +++ b/src/DataSource/Http.elm @@ -407,10 +407,23 @@ requestRaw request__ expect = ) ) |> toResult - |> DataSource.mapError (\error -> Exception.Catchable error "TODO - error message here") + |> DataSource.mapError + (\error -> + Exception.Catchable error (errorToString error) + ) ) +errorToString : Pages.StaticHttpRequest.Error -> String +errorToString error = + case error of + Pages.StaticHttpRequest.DecoderError string -> + string + + Pages.StaticHttpRequest.UserCalledStaticHttpFail string -> + string + + {-| -} type alias Metadata = { url : String diff --git a/tests/StaticHttpRequestsTests.elm b/tests/StaticHttpRequestsTests.elm index 3c3c1c29..04b122aa 100644 --- a/tests/StaticHttpRequestsTests.elm +++ b/tests/StaticHttpRequestsTests.elm @@ -305,11 +305,11 @@ all = "toJsPort" (Codec.decoder (ToJsPayload.successCodecNew2 "" "")) (expectErrorsPort - """-- CALLED STATIC HTTP FAIL ----------------------------------------------------- elm-pages + """-- INTERNAL ERROR ----------------------------------------------------- elm-pages -I ran into a call to `DataSource.fail` with message: String was not uppercased""" +String was not uppercased""" ) , test "POST method works" <| \() -> @@ -392,7 +392,7 @@ I ran into a call to `DataSource.fail` with message: String was not uppercased"" "toJsPort" (Codec.decoder (ToJsPayload.successCodecNew2 "" "")) (expectErrorsPort - """-- STATIC HTTP DECODING ERROR ----------------------------------------------------- elm-pages + """-- INTERNAL ERROR ----------------------------------------------------- elm-pages Problem with the given value: