I have a snippet of code that builds a command button for use in another program. I am using a bitmap image for the icon of this button. If I spell the name of the bitmap image incorrectly it doesn't work.
So I set up a Try Catch block to catch this. It works but the trouble I am having now is that it is a generic catch block (just the word Catch). I would like to setup a specific Catch block (like Catch e as System.DivideByZeroException) but I don't know the specific exception I am trapping in this case.
If I Catch the error shouldn't I be able to figure out what the error was? When I use e.Message I get :
'null' is not a valid value for 'stream'
The calling code is :
Try
Dim strPath As String = "ArcGIS_ll.happy1.bmp"
m_bitmap = New System.Drawing.Bitmap((Me.GetType.Assembly.GetManifestResourceStream(strPath)))
' Throw New BogusImageFilePath(strPath)
Catch e As System.Exception
Debug.WriteLine("Bogus image file", e.Message)
' Throw New BogusImageFilePath(strPath)
End Try
How can I setup a more refined Catch statement so that I will know if a different error has occured?
So I set up a Try Catch block to catch this. It works but the trouble I am having now is that it is a generic catch block (just the word Catch). I would like to setup a specific Catch block (like Catch e as System.DivideByZeroException) but I don't know the specific exception I am trapping in this case.
If I Catch the error shouldn't I be able to figure out what the error was? When I use e.Message I get :
'null' is not a valid value for 'stream'
The calling code is :
Try
Dim strPath As String = "ArcGIS_ll.happy1.bmp"
m_bitmap = New System.Drawing.Bitmap((Me.GetType.Assembly.GetManifestResourceStream(strPath)))
' Throw New BogusImageFilePath(strPath)
Catch e As System.Exception
Debug.WriteLine("Bogus image file", e.Message)
' Throw New BogusImageFilePath(strPath)
End Try
How can I setup a more refined Catch statement so that I will know if a different error has occured?