Skip to content

Commit

Permalink
#15 Added error handling interface
Browse files Browse the repository at this point in the history
  • Loading branch information
dfirsht committed Feb 29, 2016
1 parent e7481d6 commit db297b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions KituraRouter/Router.swift
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,11 @@ public class Router {
return self
}

// MARK: error
public func error(handler: RouterHandler) -> Router {
return routingHelper(.Error, pattern: nil, handler: handler)
}

private func routingHelper(method: RouterMethod, pattern: String?, handler: RouterHandler) -> Router {
routeElems.append(RouterElement(method: method, pattern: pattern, handler: handler))
return self
Expand Down
5 changes: 4 additions & 1 deletion KituraRouter/RouterElement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ class RouterElement {
///
enum RouterMethod :Int {

case All, Get, Post, Put, Head, Delete, Options, Trace, Copy, Lock, MkCol, Move, Purge, PropFind, PropPatch, Unlock, Report, MkActivity, Checkout, Merge, MSearch, Notify, Subscribe, Unsubscribe, Patch, Search, Connect, Unknown
case All, Get, Post, Put, Head, Delete, Options, Trace, Copy, Lock, MkCol, Move, Purge, PropFind, PropPatch, Unlock, Report, MkActivity, Checkout, Merge, MSearch, Notify, Subscribe, Unsubscribe, Patch, Search, Connect, Error, Unknown


init(string: String) {
Expand Down Expand Up @@ -376,6 +376,9 @@ enum RouterMethod :Int {
case "connect":
self = .Connect
break
case "error":
self = .Error
break
default:
self = .Unknown
}
Expand Down

0 comments on commit db297b8

Please sign in to comment.