Skip to content

Commit

Permalink
Show failing URL if possible (trustwallet#607)
Browse files Browse the repository at this point in the history
* show failing URL

* Add changeURL method
  • Loading branch information
hewigovens authored and vikmeup committed Apr 13, 2018
1 parent bdc2fb2 commit 97bb5f6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Trust/Browser/ViewControllers/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class BrowserViewController: UIViewController {
}()

weak var delegate: BrowserViewControllerDelegate?

var browserNavBar: BrowserNavigationBar? {
return navigationController?.navigationBar as? BrowserNavigationBar
}
Expand Down Expand Up @@ -180,6 +180,10 @@ class BrowserViewController: UIViewController {
delegate?.didVisitURL(url: url, title: webView.title ?? "")
}

private func changeURL(_ url: URL) {
delegate?.runAction(action: .changeURL(url))
}

private func hideErrorView() {
errorView.isHidden = true
}
Expand All @@ -198,7 +202,7 @@ class BrowserViewController: UIViewController {
} else if keyPath == Keys.URL {
if let url = webView.url {
self.browserNavBar?.textField.text = url.absoluteString
self.delegate?.runAction(action: .changeURL(url))
changeURL(url)
}
}
}
Expand Down Expand Up @@ -226,6 +230,10 @@ class BrowserViewController: UIViewController {
if error.code == NSURLErrorCancelled {
return
} else {
if error.domain == NSURLErrorDomain,
let failedURL = (error as NSError).userInfo[NSURLErrorFailingURLErrorKey] as? URL {
changeURL(failedURL)
}
errorView.show(error: error)
}
}
Expand Down

0 comments on commit 97bb5f6

Please sign in to comment.