webchat: surface bootstrap errors in UI
parent
dc22661744
commit
be87cdddeb
|
|
@ -124,7 +124,9 @@ final class WebChatWindowController: NSWindowController, WKScriptMessageHandler,
|
||||||
self.loadPage(baseURL: endpoint.appendingPathComponent("webchat/"))
|
self.loadPage(baseURL: endpoint.appendingPathComponent("webchat/"))
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
webChatLogger.error("webchat bootstrap failed: \(error.localizedDescription, privacy: .public)")
|
let message = error.localizedDescription
|
||||||
|
webChatLogger.error("webchat bootstrap failed: \(message, privacy: .public)")
|
||||||
|
await MainActor.run { self.showError(message) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -153,6 +155,13 @@ final class WebChatWindowController: NSWindowController, WKScriptMessageHandler,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func showError(_ text: String) {
|
||||||
|
let html = """
|
||||||
|
<html><body style='font-family:-apple-system;padding:24px;color:#c00'>Web chat failed to connect.<br><br>\(text)</body></html>
|
||||||
|
"""
|
||||||
|
self.webView.loadHTMLString(html, baseURL: nil)
|
||||||
|
}
|
||||||
|
|
||||||
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
|
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
|
||||||
webChatLogger.debug("didFinish navigation url=\(webView.url?.absoluteString ?? "nil", privacy: .public)")
|
webChatLogger.debug("didFinish navigation url=\(webView.url?.absoluteString ?? "nil", privacy: .public)")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue