[Ikvm-developers] Exception handling
Brought to you by:
jfrijters
From: Igor K. <sha...@gm...> - 2013-08-29 20:36:54
|
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 |