/** * Convert a JavaException (from the bridge) into a human-readable PHP Exception. * * Basically this just copies the stack trace of the java exception into the Exception's message and throws a normal Exception. * * @param object JavaException The exception from the bridge. * @throws object Exception The PHP Exception with the java stack trace. */ private function handleJavaException(JavaException $e) { $trace = new java("java.io.ByteArrayOutputStream"); $e->printStackTrace(new java("java.io.PrintStream", $trace)); throw new Exception("java exception {$e->getMessage()}, stack trace:<pre> {$trace} </pre>\n"); }