public static java.lang.Throwable TranslateException(java.lang.Throwable exc) { System.Exception newExc = null; if (exc is system.Exception) { return(exc); } var dlg = (ExceptionTranslator)exceptionMap.get( ((java.lang.Object)(object) exc).getClass()); if (dlg != null) { newExc = dlg(exc); } if (newExc == null) { if (exc is java.lang.NullPointerException) { newExc = new System.NullReferenceException(); } /*if (exc is java.lang.IllegalArgumentException) * newExc = new System.ArgumentException();*/ if (exc is java.lang.ArithmeticException && exc.getMessage() == "/ by zero") { newExc = new System.DivideByZeroException(); // "Attempted to divide by zero." } // also: IndexOutOfRangeException. define in Array? not necessarily. // fixme: move these to specialized exceptionMap ? if (newExc == null) { return(exc); } /*if (newExc == null) * { * // any throwable not deriving from system.Exception is assumed * // to be coming from the JVM or java code. If it was not mapped * // to some known .NET exception, wrap it in an ExternalException * // newExc = new Exception("Java exception: " + exc.GetType()); * // fixme System.Runtime.InteropServices.ExternalException ??? * Console.WriteLine("Created New Exception: "); * Console.WriteLine(newExc); * Console.WriteLine("Continuing..."); * }*/ } java.lang.Throwable newThrowable = (java.lang.Throwable)newExc; newThrowable.setStackTrace(exc.getStackTrace()); return(newThrowable); }