Search in sources :

Example 1 with OtpErlangException

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

the class ErlangProcess method addStackTrace.

private void addStackTrace(final OtpErlangTuple savedStackTrace) {
    try {
        final OtpBindings bind = OtpErlang.match("{saved_stacktrace, _,STrace}", savedStackTrace);
        if (bind != null) {
            final Collection<OtpErlangObject> trace = bind.getList("STrace");
            for (final OtpErlangObject oframe : trace) {
                final OtpErlangTuple frame = (OtpErlangTuple) oframe;
                final OtpErlangAtom m = (OtpErlangAtom) frame.elementAt(0);
                final OtpErlangAtom f = (OtpErlangAtom) frame.elementAt(1);
                final OtpErlangLong a = (OtpErlangLong) frame.elementAt(2);
                try {
                    stackFrames.add(new ErlangUninterpretedStackFrame(m.atomValue(), new ErlangFunction(f.atomValue(), a.intValue()), this, getDebugTarget()));
                } catch (final OtpErlangRangeException e) {
                    ErlLogger.error(e);
                }
            }
        }
    } catch (final OtpParserException e1) {
        // ignore
        ErlLogger.error(e1);
    } catch (final OtpErlangException e1) {
        ErlLogger.error(e1);
    }
}
Also used : OtpErlangLong(com.ericsson.otp.erlang.OtpErlangLong) OtpParserException(org.erlide.util.erlang.OtpParserException) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangException(com.ericsson.otp.erlang.OtpErlangException) OtpBindings(org.erlide.util.erlang.OtpBindings) ErlangFunction(org.erlide.engine.model.erlang.ErlangFunction) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom)

Example 2 with OtpErlangException

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

the class TestResultsView method formatTitle.

private String formatTitle(final OtpErlangObject value) {
    try {
        final OtpBindings b = OtpErlang.match("{D,S,C}", value);
        final String suite = b.getAtom("S");
        final String tcase = b.getAtom("C");
        if (tcase.isEmpty()) {
            return "suite " + suite;
        }
        return "suite " + suite + "; case " + tcase;
    } catch (final OtpParserException e) {
    } catch (final OtpErlangException e) {
    }
    return value.toString();
}
Also used : OtpParserException(org.erlide.util.erlang.OtpParserException) OtpErlangException(com.ericsson.otp.erlang.OtpErlangException) OtpBindings(org.erlide.util.erlang.OtpBindings)

Example 3 with OtpErlangException

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

the class GeneraliseFunctionRefactoring method createPositionList.

/**
 * Returns IErlRange, OtpErlangTuple pairs, which are represents the same
 * position in a module
 *
 * @param thePositions
 * @return
 */
protected HashMap<IErlRange, OtpErlangTuple> createPositionList(final OtpErlangList thePositions) {
    try {
        final HashMap<IErlRange, OtpErlangTuple> ret = new HashMap<>();
        final IErlMemberSelection sel = (IErlMemberSelection) GlobalParameters.getWranglerSelection();
        for (final OtpErlangObject o : thePositions) {
            // {{sl, sc}, {el,ec}}
            final OtpErlangTuple pos = (OtpErlangTuple) o;
            ret.put(new ErlRange(new Range(pos), sel.getDocument()), pos);
        }
        return ret;
    } catch (final OtpErlangException e) {
        ErlLogger.error(e);
        return null;
    }
}
Also used : IErlRange(org.erlide.wrangler.refactoring.util.IErlRange) HashMap(java.util.HashMap) IErlMemberSelection(org.erlide.wrangler.refactoring.selection.IErlMemberSelection) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangException(com.ericsson.otp.erlang.OtpErlangException) ErlRange(org.erlide.wrangler.refactoring.util.ErlRange) IErlRange(org.erlide.wrangler.refactoring.util.IErlRange) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) Range(org.erlide.wrangler.refactoring.util.Range) ErlRange(org.erlide.wrangler.refactoring.util.ErlRange) IErlRange(org.erlide.wrangler.refactoring.util.IErlRange)

Example 4 with OtpErlangException

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

the class DebuggerEventFactory method parse.

public static DebuggerEvent parse(final OtpErlangObject message) {
    // TODO More events from dbg_mon...
    try {
        OtpBindings b = OtpErlang.match("{started, Pid:p}", message);
        if (b != null) {
            return DebuggerEventFactory.buildStartedEvent(b);
        }
        b = OtpErlang.match("{terminated, Pid:p}", message);
        if (b != null) {
            return DebuggerEventFactory.buildTerminatedEvent(b);
        }
        b = OtpErlang.match("{int, Cmd}", message);
        if (b != null) {
            return DebuggerEventFactory.buildIntEvent(b);
        }
        b = OtpErlang.match("{attached, Pid:p}", message);
        if (b != null) {
            return DebuggerEventFactory.buildAttachedEvent(b);
        }
        b = OtpErlang.match("{Other:a, Cmd}", message);
        if (b != null) {
            return DebuggerEventFactory.buildUnknownEvent(message);
        }
        b = OtpErlang.match("{Meta:p, Event}", message);
        if (b != null) {
            return DebuggerEventFactory.buildMetaEvent(b);
        }
    } catch (final OtpParserException e) {
        ErlLogger.error(e);
    } catch (final OtpErlangException e) {
        ErlLogger.error(e);
    }
    return new UnknownEvent(message);
}
Also used : OtpParserException(org.erlide.util.erlang.OtpParserException) OtpErlangException(com.ericsson.otp.erlang.OtpErlangException) OtpBindings(org.erlide.util.erlang.OtpBindings)

Example 5 with OtpErlangException

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

the class IOServer method processRequest.

private OtpErlangObject processRequest(final OtpErlangPid from, final OtpErlangObject arequest) {
    if (callback == null) {
        return error;
    }
    OtpBindings b;
    try {
        if (arequest instanceof OtpErlangTuple) {
            final OtpErlangTuple request = (OtpErlangTuple) arequest;
            final String tag = ((OtpErlangAtom) request.elementAt(0)).atomValue();
            if ("put_chars".equals(tag)) {
                b = OtpErlang.match("{put_chars, Chars}", request);
                if (b != null) {
                    return callback.putChars(from, IOEncoding.latin1, b.get("Chars"));
                }
                b = OtpErlang.match("{put_chars, Enc:a, Chars}", request);
                if (b != null) {
                    final String enc = b.getAtom("Enc");
                    return callback.putChars(from, IOEncoding.valueOf(enc), b.get("Chars"));
                }
                b = OtpErlang.match("{put_chars, M:a, F:a, A}", request);
                if (b != null) {
                    final String m = b.getAtom("M");
                    final String f = b.getAtom("F");
                    final Collection<OtpErlangObject> a = b.getList("A");
                    return callback.putChars(from, IOEncoding.latin1, m, f, a);
                }
                b = OtpErlang.match("{put_chars, Enc:a, M:a, F:a, A}", request);
                if (b != null) {
                    final String enc = b.getAtom("Enc");
                    final String m = b.getAtom("M");
                    final String f = b.getAtom("F");
                    final Collection<OtpErlangObject> a = b.getList("A");
                    return callback.putChars(from, IOEncoding.valueOf(enc), m, f, a);
                }
                return error;
            } else if ("get_until".equals(tag)) {
                b = OtpErlang.match("{get_until, Prompt}", request);
                if (b != null) {
                    return callback.getUntil(IOEncoding.latin1, b.get("Prompt"));
                }
                b = OtpErlang.match("{get_until, Prompt, N:i}", request);
                if (b != null) {
                    final long n = b.getLong("N");
                    return callback.getUntil(IOEncoding.latin1, b.get("Prompt"), n);
                }
                b = OtpErlang.match("{get_until, Enc:a, Prompt}", request);
                if (b != null) {
                    final String enc = b.getAtom("Enc");
                    return callback.getUntil(IOEncoding.valueOf(enc), b.get("Prompt"));
                }
                b = OtpErlang.match("{get_until, Enc:a, Prompt, N:i}", request);
                if (b != null) {
                    final String enc = b.getAtom("Enc");
                    final long n = b.getLong("N");
                    return callback.getUntil(IOEncoding.valueOf(enc), b.get("Prompt"), n);
                }
                b = OtpErlang.match("{get_until, Prompt, M:a, F:a, A}", request);
                if (b != null) {
                    final String m = b.getAtom("M");
                    final String f = b.getAtom("F");
                    final Collection<OtpErlangObject> a = b.getList("A");
                    return callback.getUntil(IOEncoding.latin1, b.get("Prompt"), m, f, a);
                }
                b = OtpErlang.match("{get_until, Enc: a, Prompt, M:a, F:a, A}", request);
                if (b != null) {
                    final String enc = b.getAtom("Enc");
                    final String m = b.getAtom("M");
                    final String f = b.getAtom("F");
                    final Collection<OtpErlangObject> a = b.getList("A");
                    return callback.getUntil(IOEncoding.valueOf(enc), b.get("Prompt"), m, f, a);
                }
            } else if ("requests".equals(tag)) {
                b = OtpErlang.match("{requests, Reqs:lx}", request);
                if (b != null) {
                    final Collection<OtpErlangObject> reqs = b.getList("Reqs");
                    OtpErlangObject val = null;
                    for (final OtpErlangObject r : reqs) {
                        val = processRequest(from, r);
                        if (val.equals(error)) {
                            return error;
                        }
                    }
                    return val == null ? error : val;
                }
            } else if ("setopts".equals(tag)) {
                b = OtpErlang.match("{setopts, Opts:lx}", request);
                if (b != null) {
                    final Collection<OtpErlangObject> opts = b.getList("Opts");
                    return callback.setOpts(opts);
                }
            } else if ("get_geometry".equals(tag)) {
                return OtpErlang.mkTuple(new OtpErlangAtom("error"), new OtpErlangAtom("enotsup"));
            } else {
                return error;
            }
        } else if (arequest instanceof OtpErlangAtom) {
            final OtpErlangAtom tag = (OtpErlangAtom) arequest;
            if ("getopts".equals(tag.atomValue())) {
                return callback.getOpts();
            }
            return error;
        } else {
            return error;
        }
    } catch (final OtpParserException e) {
        ErlLogger.error(e);
    } catch (final OtpErlangException e) {
        ErlLogger.error(e);
    }
    return error;
}
Also used : OtpParserException(org.erlide.util.erlang.OtpParserException) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangException(com.ericsson.otp.erlang.OtpErlangException) OtpBindings(org.erlide.util.erlang.OtpBindings) Collection(java.util.Collection) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom)

Aggregations

OtpErlangException (com.ericsson.otp.erlang.OtpErlangException)8 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)5 OtpBindings (org.erlide.util.erlang.OtpBindings)5 OtpParserException (org.erlide.util.erlang.OtpParserException)5 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)3 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)2 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)2 OtpErlangBinary (com.ericsson.otp.erlang.OtpErlangBinary)1 OtpErlangLong (com.ericsson.otp.erlang.OtpErlangLong)1 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)1 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 ErlangFunction (org.erlide.engine.model.erlang.ErlangFunction)1 IErlMemberSelection (org.erlide.wrangler.refactoring.selection.IErlMemberSelection)1 ErlRange (org.erlide.wrangler.refactoring.util.ErlRange)1 IErlRange (org.erlide.wrangler.refactoring.util.IErlRange)1 Range (org.erlide.wrangler.refactoring.util.Range)1