2016-07-17 11:26:22 +00:00
|
|
|
# Exceptions for 404 and custom errors are defined here.
|
2016-02-14 10:43:25 +00:00
|
|
|
module Kemal::Exceptions
|
2016-11-04 08:49:11 +00:00
|
|
|
class InvalidPathStartException < Exception
|
2017-08-25 13:41:02 +00:00
|
|
|
def initialize(method : String, path : String)
|
2016-11-04 08:12:35 +00:00
|
|
|
super "Route declaration #{method} \"#{path}\" needs to start with '/', should be #{method} \"/#{path}\""
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-02-14 10:43:25 +00:00
|
|
|
class RouteNotFound < Exception
|
2017-08-25 13:41:02 +00:00
|
|
|
def initialize(context : HTTP::Server::Context)
|
2018-06-30 12:12:13 +00:00
|
|
|
super "Requested path: '#{context.request.method}:#{context.request.path}' was not found."
|
2016-02-14 10:43:25 +00:00
|
|
|
end
|
|
|
|
end
|
2016-05-05 19:35:36 +00:00
|
|
|
|
|
|
|
class CustomException < Exception
|
2017-08-25 13:41:02 +00:00
|
|
|
def initialize(context : HTTP::Server::Context)
|
2016-05-05 20:34:07 +00:00
|
|
|
super "Rendered error with #{context.response.status_code}"
|
2016-05-05 19:35:36 +00:00
|
|
|
end
|
|
|
|
end
|
2016-02-14 10:43:25 +00:00
|
|
|
end
|