From fc09d979e4c753377131684b1100c250e89765ea Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Sun, 10 May 2020 18:08:26 +0200 Subject: ... --- src/shared/elm/Shared/Util/Http.elm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/shared/elm/Shared/Util/Http.elm (limited to 'src/shared/elm/Shared/Util/Http.elm') diff --git a/src/shared/elm/Shared/Util/Http.elm b/src/shared/elm/Shared/Util/Http.elm new file mode 100644 index 0000000..2e57819 --- /dev/null +++ b/src/shared/elm/Shared/Util/Http.elm @@ -0,0 +1,22 @@ +module Shared.Util.Http exposing (error_to_string) + +import Http + +error_to_string : Http.Error -> String +error_to_string error = + case error of + (Http.BadUrl string) -> ("Invalid URL: \"" ++ string ++ "\"") + Http.Timeout -> "Timed out" + Http.NetworkError -> "Connection lost, network error." + (Http.BadStatus response) -> + ( + "The HTTP request failed: " + ++ (String.fromInt response) + ++ "." + ) + (Http.BadBody string) -> + ( + "Server response not understood:\"" + ++ string + ++ "\"." + ) -- cgit v1.2.3-70-g09d2