1
0
mirror of https://github.com/avinal/avinal.github.io.git synced 2026-07-04 07:40:09 +05:30
Files
avinal.github.io/src/Utils/Utils.elm
T
2023-01-02 12:45:21 +05:30

35 lines
855 B
Elm

module Utils.Utils exposing (..)
import Http exposing (Error(..))
import Utils.Constants exposing (..)
contentUrl : { category : String, post : String } -> String
contentUrl { category, post } =
contentUrlPrefix ++ "posts/" ++ category ++ "/" ++ post ++ ".md"
errorToString : Http.Error -> String
errorToString error =
case error of
BadUrl url ->
"The URL " ++ url ++ " was invalid"
Timeout ->
"Unable to reach the server, try again"
NetworkError ->
"Unable to reach the server, check your network connection"
BadStatus 500 ->
"The server had a problem, try again later"
BadStatus 400 ->
"Verify your information and try again"
BadStatus _ ->
"Unknown error"
BadBody errorMessage ->
errorMessage