Exceptions

  • Thread starter Thread starter pnp
  • Start date Start date
P

pnp

Is there a way to know if an exception is thrown from an object without the
use of try-catch blocks? For example with the use of events?

Thanks in advance,
pnp
 
pnp,

Generally speaking, there is not. Unless the object has an event
exposed that specifically does this, you won't be able to get this.

You might be able to get it if attach to the ExceptionThrown event on
the AppDomain that represents the current app domain. However, this will
only allow you to detect exceptions that have not been handled.

Hope this helps.
 
Is there a way to know if an exception is thrown from an
object without the
use of try-catch blocks?

If you've not a catch and an exception is thrown, you
will know istantly--your code will die right there.
For example with the use of events?
I
If on the other hand you want to know if you can design
an error indicator from one of your objects, then the
answer is yes. The limit is only your imagination. In
ancient times they used return values to indicate success
or failure of a routine. I've even seen opinion
expressed for "pure functions" that return true for
success and false for everything else with appropriate
side effects to pass by reference arguments.
 
Back
Top