AnsweredAssumed Answered

How to propagate exceptions?

Question asked by warpengine on Apr 25, 2020
Latest reply on Jul 26, 2020 by wkaiser-esristaff

So I just started with a Pro add-in and have added a DockPane. The user fills in input and I send that to a geoprocessing function. In the DockPane I have a button with a click event


Private Sub btnGo_Click(sender As Object, e As RoutedEventArgs) Handles btnGo.Click

      'collect WPF form info

   Catch ex As Exception
      MessageBox.Show(ex.Message, "Exception", MessageBoxButton.OK, MessageBoxImage.Error)
   End Try
End Sub


In a separate module I have


Public Async Sub DoGp(ByVal vg As Info)

   Dim toolPath As String = "management.CreateFishnet"
   Dim progDlg As ProgressDialog = New ProgressDialog("Running Geoprocessing Tool", "Cancel", 100, True)
   Dim progSrc As CancelableProgressorSource = New CancelableProgressorSource(progDlg)
   Dim res As IGPResult = Await Geoprocessing.ExecuteToolAsync(toolPath, params, envr, progSrc.Progressor, GPExecuteToolFlags.Default)
   If res.IsFailed Then Throw New Exception("Geoprocessing tool failed.")

Catch ex As Exception
   Throw  'crashes here
End Try
End Sub


When I run it and there is an error in the output there is an unhandled exception at the line Throw:

An exception of type 'System.Exception' occurred in MyAddin.dll but was not handled in user code
Geoprocessing tool failed.


I have Try-Catch in the calling code and also in the module so why is it not propagated?