/** * Test catching the user exception, thrown on the remote side. */ public void testUserException() { System.out.println("**** Test user exception:"); ExceptionList exList = orb.create_exception_list(); exList.add(WeThrowThisExceptionHelper.type()); Request rq = object._create_request(null, "throwException", orb.create_list(1), null, exList, null ); rq.add_in_arg().insert_long(123); rq.invoke(); UnknownUserException uku = (UnknownUserException) rq.env().exception(); WeThrowThisException our_exception = WeThrowThisExceptionHelper.extract(uku.except); System.out.println(" Our user exception, field " + our_exception.ourField + ", has been thrown on remote side." ); }
/** @inheritDoc */ public Any received_exception() { if (m_exception_id == null) return null; if (m_sys_ex != null) { Any a = orb.create_any(); ObjectCreator.insertSysException(a, m_sys_ex); return a; } Exception mex = m_environment.exception(); UnknownUserException ex = (UnknownUserException) mex; if (ex == null) return null; else return ex.except; }
public static org.omg.CORBA.UnknownUserException read(org.omg.CORBA.portable.InputStream in, org.omg.CORBA.TypeCode[] types) { String name = in.read_string(); try { if (types != null) for (int i = 0; i < types.length; i++) { if (types[i].kind().value() != TCKind._tk_except) throw new BAD_PARAM("Bad ExceptionList: not Exception TypeCode"); if (name.equals(types[i].name())) { Any any = in.orb().create_any(); any.read_value(in, types[i]); return new UnknownUserException(any); } } } catch (BadKind bk) {} throw new UNKNOWN("Unexpected exception: " + name); }
public Exception unmarshalDIIUserException(String repoId, InputStream is) { if (! isDIIRequest()) { return null; } ExceptionList _exceptions = diiRequest.exceptions(); try { // Find the typecode for the exception for (int i=0; i<_exceptions.count() ; i++) { TypeCode tc = _exceptions.item(i); if ( tc.id().equals(repoId) ) { // Since we dont have the actual user exception // class, the spec says we have to create an // UnknownUserException and put it in the // environment. Any eany = orb.create_any(); eany.read_value(is, (TypeCode)tc); return new UnknownUserException(eany); } } } catch (Exception b) { throw wrapper.unexpectedDiiException(b); } // must be a truly unknown exception return wrapper.unknownCorbaExc( CompletionStatus.COMPLETED_MAYBE); }
/** * Set the exception that has been thrown. */ public void set_exception(Any exc) { request.env().exception(new UnknownUserException(exc)); }
/** * Make an invocation and store the result in the fields of this Request. Used * with DII only. */ public void invoke() { InvokeHandler handler = object.getHandler(operation(), cookie, false); if (handler instanceof DynamicImpHandler) { DynamicImplementation dyn = ((DynamicImpHandler) handler).servant; if (serverRequest == null) { serverRequest = new LocalServerRequest(this); } try { poa.m_orb.currents.put(Thread.currentThread(), this); dyn.invoke(serverRequest); } finally { poa.m_orb.currents.remove(Thread.currentThread()); } } else { org.omg.CORBA.portable.InputStream input = v_invoke(handler); if (!exceptionReply) { NamedValue arg; // Read return value, if set. if (m_result != null) { m_result.value().read_value(input, m_result.value().type()); } // Read returned parameters, if set. if (m_args != null) { for (int i = 0; i < m_args.count(); i++) { try { arg = m_args.item(i); // Both ARG_INOUT and ARG_OUT have this binary flag set. if ((arg.flags() & ARG_OUT.value) != 0) { arg.value().read_value(input, arg.value().type()); } } catch (Bounds ex) { Unexpected.error(ex); } } } } else// User exception reply { // Prepare an Any that will hold the exception. gnuAny exc = new gnuAny(); exc.insert_Streamable(new StreamHolder(input)); UnknownUserException unuex = new UnknownUserException(exc); m_environment.exception(unuex); } } }
public void setUserException(Any exc) { m_environment.exception(new UnknownUserException(exc)); }