Hey Garry, I have a custom exception SYNDatabaseException Inherits Exception.
A simplified constructor for SYNDatabaseException is
Constructor(setError As Error)
# Error is a ENUM of SYNDatabaseException
Select Case setError
Case .invalidDatabaseName
Code = 1000 # Integer Error Code
Super.Constructor("Database name was invalid.")
End Select
The problem is when the custom exception is constructed even though the passed parameter is Error ENUM, so Throw ex As New SYNDatabaseException(.InvalidDatabaseName)... it's super constructor is called and the Error ENUM is stored in exception.message... as an integer in a string, like not even a string representation of the integer a literal integer in the string... so for testing I wasn't getting the error message I wanted and did the following after Var testEx As New SYNDatabaseException(.InvalidDatabaseName):
Messagebox(testEx.Message) # Compiles but fails saying messagebox expects a string.
Messagebox(testEx.Message.ToString()) # spits out 1000 which is the ENUM of .InvalidDatabaseName
What am I doing wrong? If I change the constructor signature to Constructor(setError As Error, goAwaySuper As Boolean) it "sort of" works as you'd expect but the exception crashes the VM rather than showing up like a normal unhandled exception in the IDE debugger, without the goAwaySuper, the exception behaves as expected showing up in the debugger but without the VM crash message.