type of Exception thrown

View: New views
3 Messages — Rating Filter:   Alert me  

type of Exception thrown

by yeeen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Is there anyway I can detect what type of Exception I have thrown?
 
Currently I am only able to detect that I have thrown an Exception, but checking if the opcode of the instruction is "throw" or "rethrow", but I can't detect the type of Exception I have thrown. I can get info from some other instruction through its operand, but throw/rethrow don't hv operand.
 
Thanks.

--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---


Re: type of Exception thrown

by Jonathan Pryor :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Oct 10, 2009, at 5:52 AM, Wee Li Yen <weeliyen@...> wrote:
Is there anyway I can detect what type of Exception I have thrown?

Yes, but it's not easy. You meed to track which type is on the top of the call stack at the point of the throw, and since that could be the result of a method call you'll need to follow all method calls. Furthermore, due to runtime conditionals you may find more than one potential type

mdoc[0, 1] provides vaguely similar functionality through the 'mdoc update --exceptions' option, but does this by instead tracking which exception types are created (which is an easier though incorrect algorithm).

 - Jon




--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---


Re: type of Exception thrown

by yeeen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

May I how do u use this option (can u provide an example)? After the exception is found, how do u print it out?
 
Thanks.

Sent: Saturday, October 10, 2009 10:50 PM
Subject: [mono-cecil] Re: type of Exception thrown

On Oct 10, 2009, at 5:52 AM, Wee Li Yen <weeliyen@...> wrote:
Is there anyway I can detect what type of Exception I have thrown?

Yes, but it's not easy. You meed to track which type is on the top of the call stack at the point of the throw, and since that could be the result of a method call you'll need to follow all method calls. Furthermore, due to runtime conditionals you may find more than one potential type

mdoc[0, 1] provides vaguely similar functionality through the 'mdoc update --exceptions' option, but does this by instead tracking which exception types are created (which is an easier though incorrect algorithm).

 - Jon



--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---