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;
}
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);
}
}
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);
}
}
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;
}
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;
}
Aggregations