Handle HTTP 404 and 500 errors

This commit is contained in:
Alex Ling 2020-03-02 16:54:29 +00:00
parent 30af64e9ca
commit 306edc3c77

View File

@ -10,7 +10,16 @@ class Server
def initialize(@context : Context) def initialize(@context : Context)
error 403 do |env| error 403 do |env|
message = "You are not authorized to visit #{env.request.path}" message = "HTTP 403: You are not authorized to visit " \
"#{env.request.path}"
layout "message"
end
error 404 do |env|
message = "HTTP 404: Mango cannot find the page #{env.request.path}"
layout "message"
end
error 500 do |env|
message = "HTTP 500: Internal server error. Please try again later."
layout "message" layout "message"
end end