git.iko.soy/gigawork-coworking/gigawork-coworking.github.io
on master help sign in
79 lines 1.4 kB history raw
1module ErrorPage exposing (ErrorPage(..), Model, Msg, head, init, internalError, notFound, statusCode, update, view)
3import Effect exposing (Effect)
4import Element exposing (..)
5import Head
6import View exposing (View)
9type Msg
10 = Increment
13type alias Model =
14 { count : Int
15 }
18init : ErrorPage -> ( Model, Effect Msg )
19init errorPage =
20 ( { count = 0 }
21 , Effect.none
22 )
25update : ErrorPage -> Msg -> Model -> ( Model, Effect Msg )
26update errorPage msg model =
27 case msg of
28 Increment ->
29 ( { model | count = model.count + 1 }, Effect.none )
32head : ErrorPage -> List Head.Tag
33head errorPage =
34 []
37type ErrorPage
38 = NotFound
39 | InternalError String
42notFound : ErrorPage
43notFound =
44 NotFound
47internalError : String -> ErrorPage
48internalError =
49 InternalError
52view : ErrorPage -> Model -> View Msg
53view error model =
54 { body =
55 text <|
56 case error of
57 NotFound ->
58 "Page not found. Maybe try another URL?"
60 InternalError string ->
61 "Something went wrong.\n" ++ string
62 , title =
63 case error of
64 NotFound ->
65 "Page Not Found"
67 InternalError string ->
68 "Unexpected Error"
69 }
72statusCode : ErrorPage -> number
73statusCode error =
74 case error of
75 NotFound ->
76 404
78 InternalError _ ->
79 500