Strange things occur sometimes. Like this error message I get when running my project under development:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Cast from type 'DBNull' to type 'Integer' is not valid.
Source Error:
Line 1348: Get
Line 1349: Try
Line 1350: Return CType(Me(Me.tableCP_P_WEBMODULES.WEBMODULE_IDColumn),Integer)
Line 1351: Catch e As InvalidCastException
Line 1352: Throw New StrongTypingException("Cannot get value because it is DBNull.", e) |
So the faulty code is in enclosed in a Try-Catch statement. The Catch-block catches an InvalidCastException. However, when that actual type of exception is thrown, it's not handled.
Surely, I can make sure that this code never throws an exception by checking the datatype before calling the method. But that doesn't explain why the exception is not caught right here. Ideas anyone?