Exemplo n.º 1
0
def exception_break(plugin, pydb, pydb_frame, frame, args, arg):
    pydb = args[0]
    thread = args[3]
    exception, value, trace = arg
    if pydb.jinja2_exception_break:
        exception_type = dict_keys(pydb.jinja2_exception_break)[0]
        if get_exception_name(exception) in ('UndefinedError', 'TemplateNotFound', 'TemplatesNotFound'):
            #errors in rendering
            render_frame = _find_jinja2_render_frame(frame)
            if render_frame:
                suspend_frame = _suspend_jinja2(pydb, thread, render_frame, CMD_ADD_EXCEPTION_BREAK, message=exception_type)
                if suspend_frame:
                    add_exception_to_frame(suspend_frame, (exception, value, trace))
                    flag = True
                    suspend_frame.f_back = frame
                    frame = suspend_frame
                    return flag, frame
        elif get_exception_name(exception) in ('TemplateSyntaxError', 'TemplateAssertionError'):
            #errors in compile time
            name = frame.f_code.co_name
            if name in ('template', 'top-level template code', '<module>') or name.startswith('block '):
                #Jinja2 translates exception info and creates fake frame on his own
                pydb_frame.set_suspend(thread, CMD_ADD_EXCEPTION_BREAK)
                add_exception_to_frame(frame, (exception, value, trace))
                thread.additional_info.suspend_type = JINJA2_SUSPEND
                thread.additional_info.pydev_message = str(exception_type)
                flag = True
                return flag, frame
    return None
Exemplo n.º 2
0
def exception_break(plugin, pydb, pydb_frame, frame, args, arg):
    pydb = args[0]
    thread = args[3]
    exception, value, trace = arg
    if pydb.jinja2_exception_break:
        exception_type = dict_keys(pydb.jinja2_exception_break)[0]
        if get_exception_name(exception) in ('UndefinedError', 'TemplateNotFound', 'TemplatesNotFound'):
            #errors in rendering
            render_frame = _find_jinja2_render_frame(frame)
            if render_frame:
                suspend_frame = _suspend_jinja2(pydb, thread, render_frame, CMD_ADD_EXCEPTION_BREAK, message=exception_type)
                if suspend_frame:
                    add_exception_to_frame(suspend_frame, (exception, value, trace))
                    flag = True
                    suspend_frame.f_back = frame
                    frame = suspend_frame
                    return flag, frame
        elif get_exception_name(exception) in ('TemplateSyntaxError', 'TemplateAssertionError'):
            #errors in compile time
            name = frame.f_code.co_name
            if name in ('template', 'top-level template code', '<module>') or name.startswith('block '):
                #Jinja2 translates exception info and creates fake frame on his own
                pydb_frame.set_suspend(thread, CMD_ADD_EXCEPTION_BREAK)
                add_exception_to_frame(frame, (exception, value, trace))
                thread.additional_info.suspend_type = JINJA2_SUSPEND
                thread.additional_info.pydev_message = str(exception_type)
                flag = True
                return flag, frame
    return None
Exemplo n.º 3
0
def exception_break(plugin, main_debugger, pydb_frame, frame, args, arg):
    main_debugger, filename, info, thread = args
    exception, value, trace = arg
    if main_debugger.django_exception_break and \
            get_exception_name(exception) in ['VariableDoesNotExist', 'TemplateDoesNotExist', 'TemplateSyntaxError'] and \
            just_raised(trace) and _is_django_exception_break_context(frame):
        render_frame = _find_django_render_frame(frame)
        if render_frame:
            suspend_frame = suspend_django(main_debugger, thread, render_frame, CMD_ADD_EXCEPTION_BREAK)
            if suspend_frame:
                add_exception_to_frame(suspend_frame, (exception, value, trace))
                flag = True
                thread.additional_info.pydev_message = 'VariableDoesNotExist'
                suspend_frame.f_back = frame
                frame = suspend_frame
                return (flag, frame)
    return None
Exemplo n.º 4
0
def exception_break(plugin, main_debugger, pydb_frame, frame, args, arg):
    main_debugger, filename, info, thread = args
    exception, value, trace = arg
    if main_debugger.django_exception_break and \
            get_exception_name(exception) in ['VariableDoesNotExist', 'TemplateDoesNotExist', 'TemplateSyntaxError'] and \
            just_raised(trace) and _is_django_exception_break_context(frame):
        render_frame = _find_django_render_frame(frame)
        if render_frame:
            suspend_frame = suspend_django(main_debugger, thread, render_frame, CMD_ADD_EXCEPTION_BREAK)
            if suspend_frame:
                add_exception_to_frame(suspend_frame, (exception, value, trace))
                flag = True
                thread.additional_info.pydev_message = 'VariableDoesNotExist'
                suspend_frame.f_back = frame
                frame = suspend_frame
                return (flag, frame)
    return None