Search in sources :

Example 1 with SignatureException

use of org.erlide.util.erlang.SignatureException in project erlide_eclipse by erlang.

the class ErlangDebugTarget method getProjectDirs.

private OtpErlangList getProjectDirs(final IProject project) {
    final IErlModel model = ErlangEngine.getInstance().getModel();
    final ErlangProjectProperties properties = model.findProject(project).getProperties();
    final String ebin = properties.getOutputDir().toPortableString();
    final Collection<IPath> srcs = properties.getSourceDirs();
    try {
        return (OtpErlangList) OtpErlang.format("[{ebin_dir, ~s}, {src_dirs, ~ls}]", ebin, srcs);
    } catch (final OtpParserException e) {
        ErlLogger.warn(e);
    } catch (final SignatureException e) {
        ErlLogger.warn(e);
    }
    return new OtpErlangList();
}
Also used : IErlModel(org.erlide.engine.model.root.IErlModel) IPath(org.eclipse.core.runtime.IPath) ErlangProjectProperties(org.erlide.engine.model.root.ErlangProjectProperties) OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpParserException(org.erlide.util.erlang.OtpParserException) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) SignatureException(org.erlide.util.erlang.SignatureException)

Example 2 with SignatureException

use of org.erlide.util.erlang.SignatureException in project erlide_eclipse by erlang.

the class OtpRpc method convertArgs.

private OtpErlangObject[] convertArgs(final String signature, final Object... args) throws SignatureException {
    final Object[] args0 = args == null ? new OtpErlangObject[] {} : args;
    Signature[] type;
    type = Signature.parse(signature);
    if (type == null) {
        type = new Signature[args0.length];
        for (int i = 0; i < args0.length; i++) {
            type[i] = new Signature('x');
        }
    }
    if (type.length != args0.length) {
        throw new SignatureException("Signature doesn't match parameter number: " + type.length + "/" + args0.length);
    }
    final OtpErlangObject[] args1 = new OtpErlangObject[args0.length];
    for (int i = 0; i < args1.length; i++) {
        args1[i] = TypeConverter.java2erlang(args0[i], type[i]);
    }
    return args1;
}
Also used : OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) Signature(org.erlide.util.erlang.Signature) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) SignatureException(org.erlide.util.erlang.SignatureException)

Example 3 with SignatureException

use of org.erlide.util.erlang.SignatureException 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 4 with SignatureException

use of org.erlide.util.erlang.SignatureException 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 5 with SignatureException

use of org.erlide.util.erlang.SignatureException 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)

Aggregations

SignatureException (org.erlide.util.erlang.SignatureException)5 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)4 RpcException (org.erlide.runtime.rpc.RpcException)3 TimeoutException (java.util.concurrent.TimeoutException)2 RpcFuture (org.erlide.runtime.rpc.RpcFuture)2 RpcTimeoutException (org.erlide.runtime.rpc.RpcTimeoutException)2 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)1 OtpErlangDecodeException (com.ericsson.otp.erlang.OtpErlangDecodeException)1 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)1 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)1 OtpMbox (com.ericsson.otp.erlang.OtpMbox)1 IPath (org.eclipse.core.runtime.IPath)1 ErlangProjectProperties (org.erlide.engine.model.root.ErlangProjectProperties)1 IErlModel (org.erlide.engine.model.root.IErlModel)1 OtpParserException (org.erlide.util.erlang.OtpParserException)1 Signature (org.erlide.util.erlang.Signature)1