Re: [Ikvm-developers] Exception handling
Brought to you by:
jfrijters
From: Igor K. <sha...@gm...> - 2013-08-30 09:06:39
|
I found the cause. It's my bad, sorry. An exception I throw in my Java code is derived from java.lang.Exception and my exception's constructor doesn't call super(). All good now, thans! Igor -----Original Message----- From: Jeroen Frijters [mailto:je...@su...] Sent: Friday, August 30, 2013 10:19 AM To: Igor Kolesnik; ikv...@li... Subject: RE: [Ikvm-developers] Exception handling 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 > > |