Search in sources :

Example 1 with OtpErlangDecodeException

use of com.ericsson.otp.erlang.OtpErlangDecodeException in project intellij-elixir by KronicDeth.

the class BeamFileImpl method buildFileStub.

public static PsiFileStub<?> buildFileStub(byte[] bytes) {
    ElixirFileStubImpl stub = new ElixirFileStubImpl();
    Beam beam = null;
    try {
        beam = Beam.from(bytes);
    } catch (IOException e) {
        LOGGER.error(e);
    } catch (OtpErlangDecodeException e) {
        LOGGER.error(e);
    }
    ModuleStub moduleStub = buildModuleStub(stub, beam);
    if (moduleStub == null) {
        stub = null;
    }
    return stub;
}
Also used : ElixirFileStubImpl(org.elixir_lang.psi.stub.impl.ElixirFileStubImpl) Beam(org.elixir_lang.beam.Beam) OtpErlangDecodeException(com.ericsson.otp.erlang.OtpErlangDecodeException) ModuleStub(org.elixir_lang.beam.psi.stubs.ModuleStub) IOException(java.io.IOException)

Example 2 with OtpErlangDecodeException

use of com.ericsson.otp.erlang.OtpErlangDecodeException in project erlide_eclipse by erlang.

the class OtpRpc method getRpcResult.

/**
 * Retrieve the result of a RPC.
 *
 * @param mbox
 * @param timeout
 * @param env
 * @return
 * @throws RpcException
 */
@Override
public OtpErlangObject getRpcResult(final OtpMbox mbox, final long timeout, final String env) throws RpcException {
    assert mbox != null;
    OtpErlangObject res = null;
    try {
        try {
            if (timeout == OtpRpc.INFINITY) {
                res = mbox.receive();
            } else {
                res = mbox.receive(timeout);
            }
            if (OtpRpc.CHECK_RPC) {
                ErlLogger.debug("RPC " + mbox.hashCode() + "<= " + res);
            }
        } finally {
            if (res != null) {
                mbox.close();
            }
        }
        if (res == null) {
            final String msg = env != null ? env : "??";
            throw new RpcTimeoutException(msg);
        }
        if (!(res instanceof OtpErlangTuple)) {
            throw new RpcException(res.toString());
        }
        final OtpErlangTuple t = (OtpErlangTuple) res;
        if (t.arity() != 2) {
            throw new RpcException(res.toString());
        }
        res = t.elementAt(1);
    } catch (final OtpErlangExit e) {
        throw new RpcException(e);
    } catch (final OtpErlangDecodeException e) {
        throw new RpcException(e);
    }
    return res;
}
Also used : OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) RpcException(org.erlide.runtime.rpc.RpcException) OtpErlangDecodeException(com.ericsson.otp.erlang.OtpErlangDecodeException) OtpErlangExit(com.ericsson.otp.erlang.OtpErlangExit) RpcTimeoutException(org.erlide.runtime.rpc.RpcTimeoutException) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple)

Example 3 with OtpErlangDecodeException

use of com.ericsson.otp.erlang.OtpErlangDecodeException in project erlide_eclipse by erlang.

the class OtpNodeProxy method receiveEventMessage.

private void receiveEventMessage(final OtpMbox eventBox) throws OtpErlangExit {
    OtpErlangObject msg = null;
    try {
        msg = eventBox.receive(OtpNodeProxy.POLL_INTERVAL);
        final ErlEvent busEvent = eventHelper.parse(msg, this);
        if (busEvent != null) {
            if (OtpNodeProxy.DEBUG) {
                ErlLogger.debug("MSG: %s", "[" + busEvent.getSender() + "::" + busEvent.getTopic() + ": " + busEvent.getEvent() + "]");
            }
            eventBus.post(busEvent);
        }
    } catch (final OtpErlangExit e) {
        ErlLogger.error(e);
        throw e;
    } catch (final OtpErlangDecodeException e) {
        ErlLogger.error(e);
    }
}
Also used : OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangDecodeException(com.ericsson.otp.erlang.OtpErlangDecodeException) OtpErlangExit(com.ericsson.otp.erlang.OtpErlangExit) ErlEvent(org.erlide.runtime.events.ErlEvent)

Aggregations

OtpErlangDecodeException (com.ericsson.otp.erlang.OtpErlangDecodeException)3 OtpErlangExit (com.ericsson.otp.erlang.OtpErlangExit)2 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)2 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)1 IOException (java.io.IOException)1 Beam (org.elixir_lang.beam.Beam)1 ModuleStub (org.elixir_lang.beam.psi.stubs.ModuleStub)1 ElixirFileStubImpl (org.elixir_lang.psi.stub.impl.ElixirFileStubImpl)1 ErlEvent (org.erlide.runtime.events.ErlEvent)1 RpcException (org.erlide.runtime.rpc.RpcException)1 RpcTimeoutException (org.erlide.runtime.rpc.RpcTimeoutException)1