aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui/ui.go
diff options
context:
space:
mode:
authorAlexander Neumann <an2048@gmail.com>2019-07-25 15:12:04 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-07-29 09:45:07 +0200
commit61a567ac0166a0cf4af42d5bdff7438176223727 (patch)
treeb267dbf46cd412aa6f13b7d87ca7a586aed08d84 /ui/ui.go
parentui: use now exposed ItemCountChanged event (diff)
downloadwireguard-windows-61a567ac0166a0cf4af42d5bdff7438176223727.tar.xz
wireguard-windows-61a567ac0166a0cf4af42d5bdff7438176223727.zip
ui: improve error handling
Signed-off-by: Alexander Neumann <an2048@gmail.com>
Diffstat (limited to 'ui/ui.go')
-rw-r--r--ui/ui.go22
1 files changed, 20 insertions, 2 deletions
diff --git a/ui/ui.go b/ui/ui.go
index aa0c7528..c98edf18 100644
--- a/ui/ui.go
+++ b/ui/ui.go
@@ -26,7 +26,7 @@ func RunUI() {
runtime.LockOSThread()
defer func() {
if err := recover(); err != nil {
- walk.MsgBox(nil, "Panic", fmt.Sprint(err, "\n\n", string(debug.Stack())), walk.MsgBoxIconError)
+ showErrorCustom(nil, "Panic", fmt.Sprint(err, "\n\n", string(debug.Stack())))
panic(err)
}
}()
@@ -95,7 +95,7 @@ func RunUI() {
if shouldQuitManagerWhenExiting {
_, err := manager.IPCClientQuit(true)
if err != nil {
- walk.MsgBox(nil, "Error Exiting WireGuard", fmt.Sprintf("Unable to exit service due to: %v. You may want to stop WireGuard from the service manager.", err), walk.MsgBoxIconError)
+ showErrorCustom(nil, "Error Exiting WireGuard", fmt.Sprintf("Unable to exit service due to: %v. You may want to stop WireGuard from the service manager.", err))
}
}
}
@@ -104,3 +104,21 @@ func onQuit() {
shouldQuitManagerWhenExiting = true
walk.App().Exit(0)
}
+
+func showError(err error, owner walk.Form) bool {
+ if err == nil {
+ return false
+ }
+
+ showErrorCustom(owner, "Error", err.Error())
+
+ return true
+}
+
+func showErrorCustom(owner walk.Form, title, message string) {
+ walk.MsgBox(owner, title, message, walk.MsgBoxIconError)
+}
+
+func showWarningCustom(owner walk.Form, title, message string) {
+ walk.MsgBox(owner, title, message, walk.MsgBoxIconWarning)
+}