import java.lang.*; //import java.net.*; import java.util.*; import java.io.*; import ti.io.*; // this is a useful hack until Titanium adds some mechanism for querying exception type directly public class ExnType { public static String gettype(Throwable mysteryexn) { String exntype; try { throw mysteryexn; } // non-subclasses exceptions catch (AbstractMethodError exn) { exntype = "AbstractMethodError"; } catch (ArithmeticException exn) { exntype = "ArithmeticException"; } catch (ArrayIndexOutOfBoundsException exn) { exntype = "ArrayIndexOutOfBoundsException"; } catch (ArrayStoreException exn) { exntype = "ArrayStoreException"; } // catch (AsyncIOCanceledException exn) { exntype = "AsyncIOCanceledException"; } catch (ClassCastException exn) { exntype = "ClassCastException"; } catch (ClassCircularityError exn) { exntype = "ClassCircularityError"; } catch (ClassFormatError exn) { exntype = "ClassFormatError"; } catch (ClassNotFoundException exn) { exntype = "ClassNotFoundException"; } catch (CloneNotSupportedException exn) { exntype = "CloneNotSupportedException"; } catch (EmptyStackException exn) { exntype = "EmptyStackException"; } catch (EOFException exn) { exntype = "EOFException"; } catch (FileNotFoundException exn) { exntype = "FileNotFoundException"; } // catch (FileNotOpenException exn) { exntype = "FileNotOpenException"; } catch (IllegalAccessError exn) { exntype = "IllegalAccessError"; } catch (IllegalAccessException exn) { exntype = "IllegalAccessException"; } catch (IllegalMonitorStateException exn) { exntype = "IllegalMonitorStateException"; } catch (IllegalThreadStateException exn) { exntype = "IllegalThreadStateException"; } catch (InstantiationError exn) { exntype = "InstantiationError"; } catch (InstantiationException exn) { exntype = "InstantiationException"; } catch (InternalError exn) { exntype = "InternalError"; } catch (InterruptedException exn) { exntype = "InterruptedException"; } catch (InterruptedIOException exn) { exntype = "InterruptedIOException"; } // catch (MalformedURLException exn) { exntype = "MalformedURLException"; } catch (NegativeArraySizeException exn) { exntype = "NegativeArraySizeException"; } catch (NoClassDefFoundError exn) { exntype = "NoClassDefFoundError"; } catch (NoSuchElementException exn) { exntype = "NoSuchElementException"; } catch (NoSuchFieldError exn) { exntype = "NoSuchFieldError"; } catch (NoSuchMethodError exn) { exntype = "NoSuchMethodError"; } catch (NoSuchMethodException exn) { exntype = "NoSuchMethodException"; } catch (NullPointerException exn) { exntype = "NullPointerException"; } catch (NumberFormatException exn) { exntype = "NumberFormatException"; } catch (OutOfMemoryError exn) { exntype = "OutOfMemoryError"; } // catch (ProtocolException exn) { exntype = "ProtocolException"; } catch (SecurityException exn) { exntype = "SecurityException"; } // catch (SocketException exn) { exntype = "SocketException"; } catch (StackOverflowError exn) { exntype = "StackOverflowError"; } catch (StringIndexOutOfBoundsException exn) { exntype = "StringIndexOutOfBoundsException"; } catch (UnknownError exn) { exntype = "UnknownError"; } // catch (UnknownHostException exn) { exntype = "UnknownHostException"; } // catch (UnknownServiceException exn) { exntype = "UnknownServiceException"; } catch (UnsatisfiedLinkError exn) { exntype = "UnsatisfiedLinkError"; } catch (UTFDataFormatException exn) { exntype = "UTFDataFormatException"; } catch (VerifyError exn) { exntype = "VerifyError"; } // exceptions that are super classes to something above, in reverse topological order catch (IncompatibleClassChangeError exn) { exntype = "IncompatibleClassChangeError"; } catch (IllegalArgumentException exn) { exntype = "IllegalArgumentException"; } catch (IndexOutOfBoundsException exn) { exntype = "IndexOutOfBoundsException"; } catch (IOException exn) { exntype = "IOException"; } catch (RuntimeException exn) { exntype = "RuntimeException"; } catch (Exception exn) { exntype = "Exception"; } catch (VirtualMachineError exn) { exntype = "VirtualMachineError"; } catch (LinkageError exn) { exntype = "LinkageError"; } catch (Error exn) { exntype = "Error"; } catch (Throwable exn) { exntype = "Throwable"; } return exntype; } }