mirror of
https://github.com/avinal/avinal.github.io.git
synced 2026-07-03 23:30: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
|
|> Html.map GotStaticMsg
|
||||||
|
|
||||||
NotFound ->
|
NotFound ->
|
||||||
text "404"
|
Splash.view (Splash.notFound (Url.toString model.url))
|
||||||
|
|> Html.map GotSplashMsg
|
||||||
in
|
in
|
||||||
{ title = model.title
|
{ title = model.title
|
||||||
, body =
|
, body =
|
||||||
@@ -201,7 +202,7 @@ toStatic model ( staticModel, cmd ) =
|
|||||||
|
|
||||||
init : () -> Url -> Nav.Key -> ( Model, Cmd Msg )
|
init : () -> Url -> Nav.Key -> ( Model, Cmd Msg )
|
||||||
init _ url key =
|
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 =
|
updateUrl model =
|
||||||
case Parser.parse parser model.url of
|
case Parser.parse parser model.url of
|
||||||
Just Splash ->
|
Just Splash ->
|
||||||
Splash.init ()
|
Splash.init () False ""
|
||||||
|> toSplash model
|
|> toSplash model
|
||||||
|
|
||||||
Just Blog ->
|
Just Blog ->
|
||||||
@@ -246,7 +247,8 @@ updateUrl model =
|
|||||||
|> toStatic model
|
|> toStatic model
|
||||||
|
|
||||||
Nothing ->
|
Nothing ->
|
||||||
( { model | page = NotFound }, Cmd.none )
|
Splash.init () True (Url.toString model.url)
|
||||||
|
|> toSplash model
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+23
-8
@@ -33,6 +33,22 @@ type Msg
|
|||||||
= Nothing
|
= 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 -> ( Model, Cmd Msg )
|
||||||
update msg model =
|
update msg model =
|
||||||
case msg of
|
case msg of
|
||||||
@@ -40,11 +56,10 @@ update msg model =
|
|||||||
( model, Cmd.none )
|
( model, Cmd.none )
|
||||||
|
|
||||||
|
|
||||||
init : () -> ( Model, Cmd Msg )
|
init : () -> Bool -> String -> ( Model, Cmd Msg )
|
||||||
init _ =
|
init _ isError error =
|
||||||
( { urls = []
|
if isError then
|
||||||
, support_message = "We are looking for the SpaceTime"
|
( notFound error, Cmd.none )
|
||||||
, error_message = "We are sorry, but we can't find the SpaceTime"
|
|
||||||
}
|
else
|
||||||
, Cmd.none
|
( default, Cmd.none )
|
||||||
)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user