Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit f28b119

Browse files
committed
log missing router and fix reference
1 parent e9b6ac5 commit f28b119

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

Classes/Issues/Referenced/IssueReferencedSectionController.swift

+1-5
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ final class IssueReferencedSectionController: ListGenericSectionController<Issue
3636
override func didSelectItem(at index: Int) {
3737
guard let object = self.object else { return }
3838
let model = IssueDetailsModel(owner: object.owner, repo: object.repo, number: object.number)
39-
let controller = IssuesViewController(
40-
client: client,
41-
model: model
42-
)
43-
viewController?.show(controller, sender: nil)
39+
viewController?.route_push(to: IssuesViewController(client: client, model: model))
4440
}
4541

4642
}

Classes/Systems/AppRouter/Router.swift

+14-13
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import Foundation
1010
import GitHawkRoutes
11+
import Crashlytics
1112

1213
private func register<T: Routable & RoutePerformable>(
1314
route: T.Type,
@@ -18,6 +19,16 @@ private func register<T: Routable & RoutePerformable>(
1819

1920
private var hasSwizzledChildViewController = false
2021

22+
private func logMissingRouter() {
23+
let trace = Thread.callStackSymbols.joined(separator: "\n")
24+
print("ERROR: Router not wired up. Callsite:")
25+
print(trace)
26+
Answers.logCustomEvent(
27+
withName: "missing-router",
28+
customAttributes: ["trace": trace]
29+
)
30+
}
31+
2132
extension UIViewController {
2233

2334
fileprivate class func swizzleChildViewController() {
@@ -68,30 +79,20 @@ extension UIViewController {
6879
}
6980
}
7081

71-
func route_push(route: Routable & RoutePerformable) {
72-
if router == nil { print("ERROR: router was not wired up") }
73-
router?.handle(route: route, from: self)
74-
}
75-
76-
func route_detail(route: Routable & RoutePerformable) {
77-
if router == nil { print("ERROR: router was not wired up") }
78-
router?.handle(route: route, from: nil)
79-
}
80-
8182
// MARK: Remove after migration
8283

8384
func route_push(to controller: UIViewController) {
84-
if router == nil { print("ERROR: router was not wired up") }
85+
if router == nil { logMissingRouter() }
8586
router?.push(from: self, to: controller)
8687
}
8788

8889
func route_detail(to controller: UIViewController) {
89-
if router == nil { print("ERROR: router was not wired up") }
90+
if router == nil { logMissingRouter() }
9091
router?.detail(controller: controller)
9192
}
9293

9394
func route_present(to controller: UIViewController) {
94-
if router == nil { print("ERROR: router was not wired up") }
95+
if router == nil { logMissingRouter() }
9596
router?.present(from: self, to: controller)
9697
}
9798

0 commit comments

Comments
 (0)