M
Mark Berry
Hi,
How can I determine whether an object is derived from another object?
My specific example is that I have a CustomError class with several specific
error types that derive from it (CustomBuinessError, CustomTechnicalError,
etc.). The CustomError base class has some extra fields that I want to log
or display when an error is handled.
I know I can check for exception types in Catch blocks. But what about in
the global.asax Application_Error event? I retrieve the exception from the
Server object:
Exception exc = Server.GetLastError().GetBaseException();
1. How can I check for a specific exception type? ("is exc a
CustomTechnicalError?")
2. How can I check whether the exception derives from CustomError? In this
case I might want to print some fields from the CustomError (whether the
specific exception is CustomBuinessError, CustomTechnicalError, or
whatever).
Thanks for any pointers,
Mark
How can I determine whether an object is derived from another object?
My specific example is that I have a CustomError class with several specific
error types that derive from it (CustomBuinessError, CustomTechnicalError,
etc.). The CustomError base class has some extra fields that I want to log
or display when an error is handled.
I know I can check for exception types in Catch blocks. But what about in
the global.asax Application_Error event? I retrieve the exception from the
Server object:
Exception exc = Server.GetLastError().GetBaseException();
1. How can I check for a specific exception type? ("is exc a
CustomTechnicalError?")
2. How can I check whether the exception derives from CustomError? In this
case I might want to print some fields from the CustomError (whether the
specific exception is CustomBuinessError, CustomTechnicalError, or
whatever).
Thanks for any pointers,
Mark