Example #1
0
void raiseExc(Box* exc_obj) {
    auto entries = getTracebackEntries();
    last_tb = std::move(entries);
    last_exc = exc_obj;

    raiseRaw(exc_obj);
}
Example #2
0
void raiseExcHelper(BoxedClass* cls, const char* msg, ...) {
    auto entries = getTracebackEntries();
    last_tb = std::move(entries);

    if (msg != NULL) {
        va_list ap;
        va_start(ap, msg);

        // printf("Raising: ");
        // vprintf(msg, ap);
        // printf("\n");
        // va_start(ap, msg);

        char buf[1024];
        vsnprintf(buf, sizeof(buf), msg, ap);

        va_end(ap);

        BoxedString* message = boxStrConstant(buf);
        Box* exc_obj = exceptionNew2(cls, message);
        raiseExc(exc_obj);
    } else {
        Box* exc_obj = exceptionNew1(cls);
        raiseExc(exc_obj);
    }
}
Example #3
0
// Have a special helper function for syntax errors, since we want to include the location
// of the syntax error in the traceback, even though it is not part of the execution:
void raiseSyntaxError(const char* msg, int lineno, int col_offset, const std::string& file, const std::string& func) {
    last_exc = exceptionNew2(SyntaxError, boxStrConstant(msg));

    auto entries = getTracebackEntries();
    last_tb = std::move(entries);
    // TODO: leaks this!
    last_tb.push_back(new LineInfo(lineno, col_offset, file, func));

    raiseRaw(last_exc);
}
Example #4
0
static const LineInfo* getMostRecentLineInfo() {
    // TODO not very efficient, could stop after the first one:
    return getTracebackEntries().back();
}
Example #5
0
void _printStacktrace() {
    _printTraceback(getTracebackEntries());
}
Example #6
0
void raiseExc(Box* exc_obj) {
    auto entries = getTracebackEntries();
    last_tb = std::move(entries);

    raiseRaw(ExcInfo(exc_obj->cls, exc_obj, None));
}