Skip to content

Commit 611d9a1

Browse files
committed
Provide more information on Routable fatalErrors
The default implementation for the function to push, pon, and change provided via protocol extension fatalErrors to notify developers that they haven't provided the required implementation. The message used in the fatalError was not informative enough. These changes make it granular to the actual function being used, as well as adding the type that caused the failure, and the route element parameters that the code was trying to act on. The new error message for push for example will look something like: ``` This routable cannot push segments. You have not implemented it. (Asked RootRoutable to push landing) ```
1 parent 1055ca8 commit 611d9a1

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

ReSwiftRouter/Routable.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,22 @@ extension Routable {
3434
_ routeElementIdentifier: RouteElementIdentifier,
3535
animated: Bool,
3636
completionHandler: @escaping RoutingCompletionHandler) -> Routable {
37-
fatalError("This routable cannot change segments. You have not implemented it.")
37+
fatalError("This routable cannot push segments. You have not implemented it. (Asked \(type(of: self)) to push \(routeElementIdentifier))")
3838
}
3939

4040
public func popRouteSegment(
4141
_ routeElementIdentifier: RouteElementIdentifier,
4242
animated: Bool,
4343
completionHandler: @escaping RoutingCompletionHandler) {
44-
fatalError("This routable cannot change segments. You have not implemented it.")
44+
fatalError("This routable cannot pop segments. You have not implemented it. (Asked \(type(of: self)) to pop \(routeElementIdentifier))")
4545
}
4646

4747
public func changeRouteSegment(
4848
_ from: RouteElementIdentifier,
4949
to: RouteElementIdentifier,
5050
animated: Bool,
5151
completionHandler: @escaping RoutingCompletionHandler) -> Routable {
52-
fatalError("This routable cannot change segments. You have not implemented it.")
52+
fatalError("This routable cannot change segments. You have not implemented it. (Asked \(type(of: self)) to change from \(from) to \(to))")
5353
}
5454

5555
}

0 commit comments

Comments
 (0)