Exemple #1
0
def _try_catch(main_fn, catch_fn, final):
    try:
        return main_fn.invoke([])
    except Exception as ex:
        if not isinstance(ex, WrappedException):
            from pixie.vm.string import String
            if isinstance(ex, Exception):
                if not we_are_translated():
                    print "Python Error Info: ", ex.__dict__, ex
                    raise
                ex = RuntimeException(rt.wrap(u"Some error"))
            else:
                ex = RuntimeException(nil)
            return catch_fn.invoke([ex])
        else:
            return catch_fn.invoke([ex._ex])
    finally:
        if final is not nil:
            final.invoke([])
Exemple #2
0
def _throw(ex):
    from pixie.vm.keyword import keyword
    if isinstance(ex, RuntimeException):
        raise WrappedException(ex)
    if rt._satisfies_QMARK_(IVector, ex):
        data = rt.nth(ex, rt.wrap(0))
        msg = rt.nth(ex, rt.wrap(1))
    elif rt._satisfies_QMARK_(ILookup, ex):
        data = rt._val_at(ex, keyword(u"data"), nil)
        msg = rt._val_at(ex, keyword(u"msg"), nil)
    else:
        affirm(False, u"Can only throw vectors, maps and exceptions")
        return nil
    raise WrappedException(RuntimeException(msg, data))
Exemple #3
0
def _try_catch(main_fn, catch_fn, final):
    from pixie.vm.keyword import keyword
    try:
        return main_fn.invoke([])
    except Exception as ex:
        if not isinstance(ex, WrappedException):
            if isinstance(ex, Exception):
                if not we_are_translated():
                    print "Python Error Info: ", ex.__dict__, ex
                    raise
                ex = RuntimeException(
                    rt.wrap(u"Internal error: " + unicode(str(ex))),
                    keyword(u"pixie.stdlib/InternalError"))
            else:
                ex = RuntimeException(
                    u"No available message",
                    keyword(u"pixie.stdlib/UnknownInternalError"))
            return catch_fn.invoke([ex])
        else:
            return catch_fn.invoke([ex._ex])
    finally:
        if final is not nil:
            final.invoke([])
Exemple #4
0
def _throw(ex):
    if isinstance(ex, RuntimeException):
        raise WrappedException(ex)
    raise WrappedException(RuntimeException(ex))