Re: [Ikvm-developers] Exception handling
Brought to you by:
jfrijters
From: Jeroen F. <je...@su...> - 2013-08-30 07:19:57
|
Hi Igor, Can you give a specific example, because the scenario you describe below works as expected (i.e. the System.Exception.Message property contains the message passed to the Java exception constructor). Regards, Jeroen > -----Original Message----- > From: Igor Kolesnik [mailto:sha...@gm...] > Sent: Thursday, August 29, 2013 22:37 > To: ikv...@li... > Subject: [Ikvm-developers] Exception handling > > Hi; > > > > In Java I have something like this > > > > throw new java.lang.Exception(message); > > > > in .NET I catch exceptions like this (it may come from both sides, .NET > and Java) > > > > catch (System.Exception e) { > > // using e here, e.Message, e.StackTrace, etc. > > } > > > > The problem here is that if an exception is coming from the Java side, > then e has no message, that is e.Message == "". > > However, I can access that message by using cast > ((java.lang.Throwable)e).getMessage(). > > > > So, what would be a recommended way to convert java.lang.Throwable to > System.Exception? A way I see is to manually parse Throwable by > extracting the fields I need and create a new System.Exception instance. > > Are there any helpers for that? > > > > Thanks > > Igor > > |