mirror of
https://github.com/avinal/avinal.github.io.git
synced 2026-07-04 07:40:09 +05:30
add better error page
Signed-off-by: Avinal Kumar <avinal.xlvii@gmail.com>
This commit is contained in:
+6
-4
@@ -75,7 +75,8 @@ view model =
|
||||
|> Html.map GotStaticMsg
|
||||
|
||||
NotFound ->
|
||||
text "404"
|
||||
Splash.view (Splash.notFound (Url.toString model.url))
|
||||
|> Html.map GotSplashMsg
|
||||
in
|
||||
{ title = model.title
|
||||
, body =
|
||||
@@ -201,7 +202,7 @@ toStatic model ( staticModel, cmd ) =
|
||||
|
||||
init : () -> Url -> Nav.Key -> ( Model, Cmd Msg )
|
||||
init _ url key =
|
||||
updateUrl { url = url, page = NotFound, title = "404", key = key }
|
||||
updateUrl { url = url, page = NotFound, title = "Be My SpaceTime", key = key }
|
||||
|
||||
|
||||
|
||||
@@ -230,7 +231,7 @@ updateUrl : Model -> ( Model, Cmd Msg )
|
||||
updateUrl model =
|
||||
case Parser.parse parser model.url of
|
||||
Just Splash ->
|
||||
Splash.init ()
|
||||
Splash.init () False ""
|
||||
|> toSplash model
|
||||
|
||||
Just Blog ->
|
||||
@@ -246,7 +247,8 @@ updateUrl model =
|
||||
|> toStatic model
|
||||
|
||||
Nothing ->
|
||||
( { model | page = NotFound }, Cmd.none )
|
||||
Splash.init () True (Url.toString model.url)
|
||||
|> toSplash model
|
||||
|
||||
|
||||
|
||||
|
||||
+23
-8
@@ -33,6 +33,22 @@ type Msg
|
||||
= Nothing
|
||||
|
||||
|
||||
notFound : String -> Model
|
||||
notFound error =
|
||||
{ urls = []
|
||||
, support_message = "We couldn't find the page you were looking for."
|
||||
, error_message = "The url " ++ error ++ " does not exist."
|
||||
}
|
||||
|
||||
|
||||
default : Model
|
||||
default =
|
||||
{ urls = []
|
||||
, support_message = "We are looking for the SpaceTime"
|
||||
, error_message = "We are sorry, but we can't find the SpaceTime"
|
||||
}
|
||||
|
||||
|
||||
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||
update msg model =
|
||||
case msg of
|
||||
@@ -40,11 +56,10 @@ update msg model =
|
||||
( model, Cmd.none )
|
||||
|
||||
|
||||
init : () -> ( Model, Cmd Msg )
|
||||
init _ =
|
||||
( { urls = []
|
||||
, support_message = "We are looking for the SpaceTime"
|
||||
, error_message = "We are sorry, but we can't find the SpaceTime"
|
||||
}
|
||||
, Cmd.none
|
||||
)
|
||||
init : () -> Bool -> String -> ( Model, Cmd Msg )
|
||||
init _ isError error =
|
||||
if isError then
|
||||
( notFound error, Cmd.none )
|
||||
|
||||
else
|
||||
( default, Cmd.none )
|
||||
|
||||
Reference in New Issue
Block a user