Search in sources :

Example 26 with RpcException

use of org.erlide.runtime.rpc.RpcException in project erlide_eclipse by erlang.

the class ErlideContextAssist method checkRecordCompletion.

public RecordCompletion checkRecordCompletion(final IOtpRpc buildBackend, final String prefix) {
    try {
        final OtpErlangObject res = buildBackend.call("erlide_content_assist", "check_record", "s", prefix);
        if (Util.isOk(res)) {
            final OtpErlangTuple t = (OtpErlangTuple) res;
            final OtpErlangTuple r = (OtpErlangTuple) t.elementAt(1);
            return new RecordCompletion(r);
        }
    } catch (final RpcException e) {
        ErlLogger.error(e);
    } catch (final OtpErlangRangeException e) {
        ErlLogger.error(e);
    }
    return null;
}
Also used : OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) RpcException(org.erlide.runtime.rpc.RpcException) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple)

Example 27 with RpcException

use of org.erlide.runtime.rpc.RpcException in project erlide_eclipse by erlang.

the class OtpRpc method async_call_result.

@Override
public void async_call_result(final IRpcResultCallback cb, final String m, final String f, final String signature, final Object... args) throws RpcException {
    final OtpErlangAtom gleader = OtpRpc.USER_ATOM;
    try {
        final Object[] args1 = new Object[args.length + 1];
        System.arraycopy(args, 0, args1, 1, args.length);
        final OtpMbox mbox = localNode.createMbox();
        args1[0] = mbox.self();
        new RpcResultReceiver(mbox, cb);
        rpcCast(localNode, nodeName, false, gleader, m, f, signature, args1);
    } catch (final SignatureException e) {
        throw new RpcException(e);
    }
}
Also used : OtpMbox(com.ericsson.otp.erlang.OtpMbox) RpcException(org.erlide.runtime.rpc.RpcException) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) SignatureException(org.erlide.util.erlang.SignatureException)

Example 28 with RpcException

use of org.erlide.runtime.rpc.RpcException in project erlide_eclipse by erlang.

the class OtpRpc method async_call_cb.

@Override
public void async_call_cb(final IRpcCallback cb, final long timeout, final OtpErlangObject gleader, final String module, final String fun, final String signature, final Object... args) throws RpcException {
    checkConnected();
    try {
        final RpcFuture future = sendRpcCall(localNode, nodeName, false, gleader, module, fun, signature, args);
        final Runnable target = new Runnable() {

            @Override
            public void run() {
                OtpErlangObject result;
                try {
                    result = future.checkedGet(timeout, TimeUnit.MILLISECONDS);
                    cb.onSuccess(result);
                } catch (final Exception e) {
                    ErlLogger.error("Could not execute RPC " + module + ":" + fun + " : " + e.getMessage());
                    cb.onFailure(e);
                }
            }
        };
        // We can't use jobs here, it's an Eclipse dependency
        OtpRpc.threadPool.execute(target);
    } catch (final SignatureException e) {
        throw new RpcException(e);
    }
}
Also used : OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) RpcException(org.erlide.runtime.rpc.RpcException) RpcFuture(org.erlide.runtime.rpc.RpcFuture) SignatureException(org.erlide.util.erlang.SignatureException) RpcTimeoutException(org.erlide.runtime.rpc.RpcTimeoutException) SignatureException(org.erlide.util.erlang.SignatureException) TimeoutException(java.util.concurrent.TimeoutException) RpcException(org.erlide.runtime.rpc.RpcException) OtpErlangDecodeException(com.ericsson.otp.erlang.OtpErlangDecodeException)

Example 29 with RpcException

use of org.erlide.runtime.rpc.RpcException in project erlide_eclipse by erlang.

the class OtpRpc method call.

@Override
public OtpErlangObject call(final long timeout, final OtpErlangObject gleader, final String module, final String fun, final String signature, final Object... args0) throws RpcException {
    checkConnected();
    OtpErlangObject result = null;
    try {
        final RpcFuture future = sendRpcCall(localNode, nodeName, false, gleader, module, fun, signature, args0);
        result = future.checkedGet(timeout, TimeUnit.MILLISECONDS);
        if (OtpRpc.CHECK_RPC) {
            ErlLogger.debug("RPC result:: " + result);
        }
        if (isBadRpc(result)) {
            throw new RpcException("Bad RPC: " + result);
        }
    } catch (final SignatureException e) {
        throw new RpcException(e);
    } catch (final TimeoutException e) {
        throw new RpcTimeoutException(e.getMessage());
    }
    return result;
}
Also used : OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) RpcException(org.erlide.runtime.rpc.RpcException) RpcFuture(org.erlide.runtime.rpc.RpcFuture) SignatureException(org.erlide.util.erlang.SignatureException) RpcTimeoutException(org.erlide.runtime.rpc.RpcTimeoutException) RpcTimeoutException(org.erlide.runtime.rpc.RpcTimeoutException) TimeoutException(java.util.concurrent.TimeoutException)

Example 30 with RpcException

use of org.erlide.runtime.rpc.RpcException in project erlide_eclipse by erlang.

the class ErlideDoc method getOtpDoc.

@Override
@SuppressWarnings("boxing")
public OtpErlangObject getOtpDoc(final IOtpRpc b, final int offset, final String module, final Collection<OtpErlangObject> imports, final String externalModules, final OtpErlangList pathVars) {
    OtpErlangObject res = null;
    try {
        final OtpErlangObject input = backend.call("erlide_open", "open", "aix", module, offset, ErlangEngine.getInstance().getOpenService().mkContext(externalModules, null, pathVars, null, imports));
        res = b.call(ErlideDoc.ERLIDE_OTP_DOC, "get_doc", "sxs", module, input, stateDir);
    } catch (final RpcException e) {
        ErlLogger.warn(e);
    }
    return res;
}
Also used : OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) RpcException(org.erlide.runtime.rpc.RpcException)

Aggregations

RpcException (org.erlide.runtime.rpc.RpcException)37 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)30 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)15 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)12 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)8 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)7 ArrayList (java.util.ArrayList)7 IOtpRpc (org.erlide.runtime.rpc.IOtpRpc)6 RpcFuture (org.erlide.runtime.rpc.RpcFuture)5 OtpErlangPid (com.ericsson.otp.erlang.OtpErlangPid)4 TimeoutException (java.util.concurrent.TimeoutException)4 CoverException (org.erlide.cover.api.CoverException)4 IErlModule (org.erlide.engine.model.root.IErlModule)4 RpcTimeoutException (org.erlide.runtime.rpc.RpcTimeoutException)4 Test (org.junit.Test)4 OtpErlangLong (com.ericsson.otp.erlang.OtpErlangLong)3 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)3 IPath (org.eclipse.core.runtime.IPath)3 IStatus (org.eclipse.core.runtime.IStatus)3 Status (org.eclipse.core.runtime.Status)3