From 87d88318de7c31acea3bc22d1065a745991c13de Mon Sep 17 00:00:00 2001 From: sdogruyol Date: Fri, 4 Nov 2016 11:49:11 +0300 Subject: [PATCH] Rename to Kemal::Exceptions::InvalidPathStartException --- spec/route_spec.cr | 2 +- src/kemal/dsl.cr | 4 ++-- src/kemal/exceptions.cr | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/route_spec.cr b/spec/route_spec.cr index 57d7688..0765281 100644 --- a/spec/route_spec.cr +++ b/spec/route_spec.cr @@ -15,7 +15,7 @@ describe "Route" do end it "doesn't allow a route declaration start without /" do - expect_raises Kemal::Exceptions::PathStartInvalidException, "Route declaration get \"route\" needs to start with '/', should be get \"/route\"" do + expect_raises Kemal::Exceptions::InvalidPathStartException, "Route declaration get \"route\" needs to start with '/', should be get \"/route\"" do get "route" do |env| "Route 1" end diff --git a/src/kemal/dsl.cr b/src/kemal/dsl.cr index 4a345c5..2512881 100644 --- a/src/kemal/dsl.cr +++ b/src/kemal/dsl.cr @@ -5,13 +5,13 @@ HTTP_METHODS = %w(get post put patch delete options) {% for method in HTTP_METHODS %} def {{method.id}}(path, &block : HTTP::Server::Context -> _) - raise Kemal::Exceptions::PathStartInvalidException.new({{method}}, path) unless Kemal::Utils.path_starts_with_backslash?(path) + raise Kemal::Exceptions::InvalidPathStartException.new({{method}}, path) unless Kemal::Utils.path_starts_with_backslash?(path) Kemal::RouteHandler::INSTANCE.add_route({{method}}.upcase, path, &block) end {% end %} def ws(path, &block : HTTP::WebSocket, HTTP::Server::Context -> Void) - raise Kemal::Exceptions::PathStartInvalidException.new("ws", path) unless Kemal::Utils.path_starts_with_backslash?(path) + raise Kemal::Exceptions::InvalidPathStartException.new("ws", path) unless Kemal::Utils.path_starts_with_backslash?(path) Kemal::WebSocketHandler.new path, &block end diff --git a/src/kemal/exceptions.cr b/src/kemal/exceptions.cr index 6d6e71d..03afa25 100644 --- a/src/kemal/exceptions.cr +++ b/src/kemal/exceptions.cr @@ -1,6 +1,6 @@ # Exceptions for 404 and custom errors are defined here. module Kemal::Exceptions - class PathStartInvalidException < Exception + class InvalidPathStartException < Exception def initialize(method, path) super "Route declaration #{method} \"#{path}\" needs to start with '/', should be #{method} \"/#{path}\"" end