From b7eaec2dcabf5d7bafc96827de8e4c3adfd8643c Mon Sep 17 00:00:00 2001 From: "Michael J. Seiferling" Date: Wed, 27 Feb 2019 18:37:12 -0600 Subject: [PATCH] Added error handling when launching external apps --- GBM/Forms/frmGameManager.vb | 28 ++++++++++++++++++---------- GBM/Forms/frmMain.vb | 18 +++++++++++++++--- GBM/My Project/Resources.Designer.vb | 9 +++++++++ GBM/My Project/Resources.resx | 3 +++ 4 files changed, 45 insertions(+), 13 deletions(-) diff --git a/GBM/Forms/frmGameManager.vb b/GBM/Forms/frmGameManager.vb index b91fde1..1841f45 100644 --- a/GBM/Forms/frmGameManager.vb +++ b/GBM/Forms/frmGameManager.vb @@ -541,11 +541,15 @@ Public Class frmGameManager sFileName = BackupFolder & CurrentBackupItem.FileName If File.Exists(sFileName) Then - oProcessStartInfo = New ProcessStartInfo - oProcessStartInfo.FileName = sFileName - oProcessStartInfo.UseShellExecute = True - oProcessStartInfo.Verb = "open" - Process.Start(oProcessStartInfo) + Try + oProcessStartInfo = New ProcessStartInfo + oProcessStartInfo.FileName = sFileName + oProcessStartInfo.UseShellExecute = True + oProcessStartInfo.Verb = "open" + Process.Start(oProcessStartInfo) + Catch ex As Exception + mgrCommon.ShowMessage(App_ErrorLaunchExternal, ex.Message, MsgBoxStyle.Exclamation) + End Try Else mgrCommon.ShowMessage(frmGameManager_ErrorNoBackupExists, MsgBoxStyle.Exclamation) End If @@ -649,11 +653,15 @@ Public Class frmGameManager End If If Directory.Exists(sPath) Then - oProcessStartInfo = New ProcessStartInfo - oProcessStartInfo.FileName = sPath - oProcessStartInfo.UseShellExecute = True - oProcessStartInfo.Verb = "open" - Process.Start(oProcessStartInfo) + Try + oProcessStartInfo = New ProcessStartInfo + oProcessStartInfo.FileName = sPath + oProcessStartInfo.UseShellExecute = True + oProcessStartInfo.Verb = "open" + Process.Start(oProcessStartInfo) + Catch ex As Exception + mgrCommon.ShowMessage(App_ErrorLaunchExternal, ex.Message, MsgBoxStyle.Exclamation) + End Try Else mgrCommon.ShowMessage(frmGameManager_ErrorNoRestorePathExists, MsgBoxStyle.Exclamation) End If diff --git a/GBM/Forms/frmMain.vb b/GBM/Forms/frmMain.vb index e588fbf..0403a90 100644 --- a/GBM/Forms/frmMain.vb +++ b/GBM/Forms/frmMain.vb @@ -1011,15 +1011,27 @@ Public Class frmMain End Sub Private Sub OpenWebSite() - Process.Start(App_URLWebsite) + Try + Process.Start(App_URLWebsite) + Catch ex As Exception + mgrCommon.ShowMessage(App_ErrorLaunchExternal, ex.Message, MsgBoxStyle.Exclamation) + End Try End Sub Private Sub OpenOnlineManual() - Process.Start(App_URLManual) + Try + Process.Start(App_URLManual) + Catch ex As Exception + mgrCommon.ShowMessage(App_ErrorLaunchExternal, ex.Message, MsgBoxStyle.Exclamation) + End Try End Sub Private Sub OpenCheckforUpdates() - Process.Start(App_URLUpdates) + Try + Process.Start(App_URLUpdates) + Catch ex As Exception + mgrCommon.ShowMessage(App_ErrorLaunchExternal, ex.Message, MsgBoxStyle.Exclamation) + End Try End Sub Private Sub CheckForNewBackups() diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb index 56e237e..317c9f6 100644 --- a/GBM/My Project/Resources.Designer.vb +++ b/GBM/My Project/Resources.Designer.vb @@ -96,6 +96,15 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to An error occured attempting to launch the application:[BR][BR][PARAM]. + ''' + Friend ReadOnly Property App_ErrorLaunchExternal() As String + Get + Return ResourceManager.GetString("App_ErrorLaunchExternal", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to This function is currently not available on a Unix based operating system.. ''' diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx index 3e781f8..b3f8eaf 100644 --- a/GBM/My Project/Resources.resx +++ b/GBM/My Project/Resources.resx @@ -2332,4 +2332,7 @@ Game Backup Monitor automatically updates the Wine configuration for a game each time it is detected. Modifying any of these fields manually is not recommended in most cases.[BR][BR]This warning will only be displayed once. + + An error occured attempting to launch the application:[BR][BR][PARAM] + \ No newline at end of file