From 986849399158b4714ca273ec8164876106bcd172 Mon Sep 17 00:00:00 2001 From: Alex Reilly Date: Sat, 27 Oct 2018 00:56:37 -0700 Subject: [PATCH] trys removed --- .../ControllerProtocols/Crudable.swift | 48 +++++++++---------- .../CrudRouter/Extensions/Router+CRUD.swift | 8 ++-- Tests/CrudRouterTests/CrudRouterTests.swift | 18 +++---- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/Sources/CrudRouter/ControllerProtocols/Crudable.swift b/Sources/CrudRouter/ControllerProtocols/Crudable.swift index 2890543..81f6988 100644 --- a/Sources/CrudRouter/ControllerProtocols/Crudable.swift +++ b/Sources/CrudRouter/ControllerProtocols/Crudable.swift @@ -8,8 +8,8 @@ public protocol Crudable: ControllerProtocol { at path: PathComponentsRepresentable..., parent relation: KeyPath>, _ either: OnlyExceptEither, - relationConfiguration: ((CrudParentController) throws -> Void)? - ) throws where + relationConfiguration: ((CrudParentController) -> Void)? + ) where ParentType: Model & Content, ChildType.Database == ParentType.Database, ParentType.ID: Parameter @@ -18,8 +18,8 @@ public protocol Crudable: ControllerProtocol { at path: PathComponentsRepresentable..., children relation: KeyPath>, _ either: OnlyExceptEither, - relationConfiguration: ((CrudChildrenController) throws -> Void)? - ) throws where + relationConfiguration: ((CrudChildrenController) -> Void)? + ) where ChildChildType: Model & Content, ChildType.Database == ChildChildType.Database, ChildChildType.ID: Parameter @@ -28,8 +28,8 @@ public protocol Crudable: ControllerProtocol { at path: PathComponentsRepresentable..., siblings relation: KeyPath>, _ either: OnlyExceptEither, - relationConfiguration: ((CrudSiblingsController) throws -> Void)? - ) throws where + relationConfiguration: ((CrudSiblingsController) -> Void)? + ) where ChildChildType: Content, ChildType.Database == ThroughType.Database, ChildChildType.ID: Parameter, @@ -43,8 +43,8 @@ public protocol Crudable: ControllerProtocol { at path: PathComponentsRepresentable..., siblings relation: KeyPath>, _ either: OnlyExceptEither, - relationConfiguration: ((CrudSiblingsController) throws -> Void)? - ) throws where + relationConfiguration: ((CrudSiblingsController) -> Void)? + ) where ChildChildType: Content, ChildType.Database == ThroughType.Database, ChildChildType.ID: Parameter, @@ -60,8 +60,8 @@ extension Crudable { at path: PathComponentsRepresentable..., parent relation: KeyPath>, _ either: OnlyExceptEither = .only([.read, .update]), - relationConfiguration: ((CrudParentController) throws -> Void)?=nil - ) throws where + relationConfiguration: ((CrudParentController) -> Void)?=nil + ) where ParentType: Model & Content, ChildType.Database == ParentType.Database, ParentType.ID: Parameter { @@ -81,17 +81,17 @@ extension Crudable { controller = CrudParentController(relation: relation, path: fullPath, router: self.router, activeMethods: allMethods.subtracting(Set(methods))) } - try controller.boot(router: self.router) + do { try controller.boot(router: self.router) } catch { fatalError("I have no reason to expect boot to throw") } - try relationConfiguration?(controller) + relationConfiguration?(controller) } public func crud( at path: PathComponentsRepresentable..., children relation: KeyPath>, _ either: OnlyExceptEither = .only([.read, .readAll, .create, .update, .delete]), - relationConfiguration: ((CrudChildrenController) throws -> Void)?=nil - ) throws where + relationConfiguration: ((CrudChildrenController) -> Void)?=nil + ) where ChildChildType: Model & Content, ChildType.Database == ChildChildType.Database, ChildChildType.ID: Parameter { @@ -110,17 +110,17 @@ extension Crudable { controller = CrudChildrenController(childrenRelation: relation, path: fullPath, router: self.router, activeMethods: allMethods.subtracting(Set(methods))) } - try controller.boot(router: self.router) + do { try controller.boot(router: self.router) } catch { fatalError("I have no reason to expect boot to throw") } - try relationConfiguration?(controller) + relationConfiguration?(controller) } public func crud( at path: PathComponentsRepresentable..., siblings relation: KeyPath>, _ either: OnlyExceptEither = .only([.read, .readAll, .create, .update, .delete]), - relationConfiguration: ((CrudSiblingsController) throws -> Void)?=nil - ) throws where + relationConfiguration: ((CrudSiblingsController) -> Void)?=nil + ) where ChildChildType: Content, ChildType.Database == ThroughType.Database, ChildChildType.ID: Parameter, @@ -145,17 +145,17 @@ extension Crudable { controller = CrudSiblingsController(siblingRelation: relation, path: fullPath, router: self.router, activeMethods: allMethods.subtracting(Set(methods))) } - try controller.boot(router: self.router) + do { try controller.boot(router: self.router) } catch { fatalError("I have no reason to expect boot to throw") } - try relationConfiguration?(controller) + relationConfiguration?(controller) } public func crud( at path: PathComponentsRepresentable..., siblings relation: KeyPath>, _ either: OnlyExceptEither = .only([.read, .readAll, .create, .update, .delete]), - relationConfiguration: ((CrudSiblingsController) throws -> Void)?=nil - ) throws where + relationConfiguration: ((CrudSiblingsController) -> Void)?=nil + ) where ChildChildType: Content, ChildType.Database == ThroughType.Database, ChildChildType.ID: Parameter, @@ -179,8 +179,8 @@ extension Crudable { controller = CrudSiblingsController(siblingRelation: relation, path: fullPath, router: self.router, activeMethods: allMethods.subtracting(Set(methods))) } - try controller.boot(router: self.router) + do { try controller.boot(router: self.router) } catch { fatalError("I have no reason to expect boot to throw") } - try relationConfiguration?(controller) + relationConfiguration?(controller) } } diff --git a/Sources/CrudRouter/Extensions/Router+CRUD.swift b/Sources/CrudRouter/Extensions/Router+CRUD.swift index 020960a..7cea3ae 100644 --- a/Sources/CrudRouter/Extensions/Router+CRUD.swift +++ b/Sources/CrudRouter/Extensions/Router+CRUD.swift @@ -6,8 +6,8 @@ public extension Router { _ path: PathComponentsRepresentable..., register type: ModelType.Type, _ either: OnlyExceptEither = .only([.read, .readAll, .create, .update, .delete]), - relationConfiguration: ((CrudController) throws -> ())?=nil - ) throws where ModelType.ID: Parameter { + relationConfiguration: ((CrudController) -> ())?=nil + ) where ModelType.ID: Parameter { let allMethods: Set = Set([.read, .readAll, .create, .update, .delete]) let controller: CrudController @@ -18,8 +18,8 @@ public extension Router { controller = CrudController(path: path, router: self, activeMethods: allMethods.subtracting(Set(methods))) } - try controller.boot(router: self) + do { try controller.boot(router: self) } catch { fatalError("I have no reason to expect boot to throw") } - try relationConfiguration?(controller) + relationConfiguration?(controller) } } diff --git a/Tests/CrudRouterTests/CrudRouterTests.swift b/Tests/CrudRouterTests/CrudRouterTests.swift index 0b7d04c..5170cdb 100644 --- a/Tests/CrudRouterTests/CrudRouterTests.swift +++ b/Tests/CrudRouterTests/CrudRouterTests.swift @@ -89,15 +89,15 @@ func configure(_ config: inout Config, _ env: inout Environment, _ services: ino } func routes(_ router: Router) throws { - try router.crud(register: Galaxy.self) { controller in - try controller.crud(children: \.planets) + router.crud(register: Galaxy.self) { controller in + controller.crud(children: \.planets) } - try router.crud(register: Planet.self) { controller in - try controller.crud(parent: \.galaxy) - try controller.crud(siblings: \.tags) + router.crud(register: Planet.self) { controller in + controller.crud(parent: \.galaxy) + controller.crud(siblings: \.tags) } - try router.crud(register: Tag.self) { controller in - try controller.crud(siblings: \.planets) + router.crud(register: Tag.self) { controller in + controller.crud(siblings: \.planets) } } @@ -165,7 +165,7 @@ final class CrudRouterTests: XCTestCase { func testBaseCrudRegistrationWithRouteName() throws { let router = EngineRouter.default() - try router.crud("planets", register: Planet.self) + router.crud("planets", register: Planet.self) XCTAssert(router.routes.isEmpty == false) XCTAssert(router.routes.count == 5) @@ -181,7 +181,7 @@ final class CrudRouterTests: XCTestCase { func testBaseCrudRegistrationWithDefaultRoute() throws { let router = EngineRouter.default() - try router.crud(register: Planet.self) + router.crud(register: Planet.self) XCTAssert(router.routes.isEmpty == false) XCTAssert(router.routes.count == 5)