mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Don't try to call error_handlers if there isn't any
This commit is contained in:
parent
dfd127e1ed
commit
63e613a439
2 changed files with 4 additions and 3 deletions
|
@ -20,7 +20,7 @@ module Kemal
|
||||||
end
|
end
|
||||||
|
|
||||||
private def call_exception_with_status_code(context : HTTP::Server::Context, exception : Exception, status_code : Int32)
|
private def call_exception_with_status_code(context : HTTP::Server::Context, exception : Exception, status_code : Int32)
|
||||||
if Kemal.config.error_handlers.has_key?(status_code)
|
if Kemal.config.error_handlers.size != 0 && Kemal.config.error_handlers.has_key?(status_code)
|
||||||
context.response.content_type = "text/html" unless context.response.headers.has_key?("Content-Type")
|
context.response.content_type = "text/html" unless context.response.headers.has_key?("Content-Type")
|
||||||
context.response.print Kemal.config.error_handlers[status_code].call(context, exception)
|
context.response.print Kemal.config.error_handlers[status_code].call(context, exception)
|
||||||
context.response.status_code = status_code
|
context.response.status_code = status_code
|
||||||
|
|
|
@ -32,10 +32,11 @@ module Kemal
|
||||||
private def process_request(context)
|
private def process_request(context)
|
||||||
raise Kemal::Exceptions::RouteNotFound.new(context) unless context.route_defined?
|
raise Kemal::Exceptions::RouteNotFound.new(context) unless context.route_defined?
|
||||||
content = context.route.handler.call(context)
|
content = context.route.handler.call(context)
|
||||||
ensure
|
|
||||||
if Kemal.config.error_handlers.has_key?(context.response.status_code)
|
if Kemal.config.error_handlers.size != 0 && Kemal.config.error_handlers.has_key?(context.response.status_code)
|
||||||
raise Kemal::Exceptions::CustomException.new(context)
|
raise Kemal::Exceptions::CustomException.new(context)
|
||||||
end
|
end
|
||||||
|
|
||||||
context.response.print(content)
|
context.response.print(content)
|
||||||
context
|
context
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue