Since all exception classes derive from System.Exception, you could use Exception itself and work with its ex.message property.
So in the same code, this should work:
See what I mean?Code:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try Throw New HairyException("Holy cow!") Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub
Now watch as I change its type to another exception thrown
Still works.Code:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try Throw New System.IO.IOException("omg lololol") Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub
Am I understanding what you want correctly?




Reply With Quote