mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-23 19:08:26 +00:00
Externalize error messages
This commit is contained in:
@ -17,6 +17,11 @@ import Process
|
||||
import Task exposing (Task)
|
||||
|
||||
|
||||
errorToString : Http.Error -> String
|
||||
errorToString _ =
|
||||
Debug.todo "remove me"
|
||||
|
||||
|
||||
|
||||
-- Authenticated Requests
|
||||
|
||||
@ -138,45 +143,6 @@ authDelete req =
|
||||
|
||||
|
||||
|
||||
-- Error Utilities
|
||||
|
||||
|
||||
errorToStringStatus : Http.Error -> (Int -> String) -> String
|
||||
errorToStringStatus error statusString =
|
||||
case error of
|
||||
Http.BadUrl url ->
|
||||
"There is something wrong with this url: " ++ url
|
||||
|
||||
Http.Timeout ->
|
||||
"There was a network timeout."
|
||||
|
||||
Http.NetworkError ->
|
||||
"There was a network error."
|
||||
|
||||
Http.BadStatus status ->
|
||||
statusString status
|
||||
|
||||
Http.BadBody str ->
|
||||
"There was an error decoding the response: " ++ str
|
||||
|
||||
|
||||
errorToString : Http.Error -> String
|
||||
errorToString error =
|
||||
let
|
||||
f sc =
|
||||
if sc == 404 then
|
||||
"The requested resource doesn't exist."
|
||||
|
||||
else if sc >= 400 && sc < 500 then
|
||||
"Invalid input when processing the request."
|
||||
|
||||
else
|
||||
"There was an invalid response status: " ++ String.fromInt sc ++ "."
|
||||
in
|
||||
errorToStringStatus error f
|
||||
|
||||
|
||||
|
||||
-- Http.Task Utilities
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user