def exception_break(plugin, pydb, pydb_frame, frame, args, arg): pydb, filename, info, thread = args exception, value, trace = arg if pydb.jinja2_exception_break: exception_type = DictKeys(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') or name.startswith('block '): #Jinja2 translates exception info and creates fake frame on his own pydb_frame.setSuspend(thread, CMD_ADD_EXCEPTION_BREAK, message=exception_type) add_exception_to_frame(frame, (exception, value, trace)) thread.additionalInfo.suspend_type = JINJA2_SUSPEND flag = True return flag, frame return None
def exception_break(plugin, pydb, pydb_frame, frame, args, arg): pydb, filename, info, thread = args exception, value, trace = arg if pydb.jinja2_exception_break: 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) 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' ) or name.startswith('block '): #Jinja2 translates exception info and creates fake frame on his own pydb_frame.setSuspend(thread, CMD_ADD_EXCEPTION_BREAK) add_exception_to_frame(frame, (exception, value, trace)) thread.additionalInfo.suspend_type = JINJA2_SUSPEND flag = True return flag, frame return None
def exception_break(mainDebugger, pydb_frame, frame, event, args, arg): mainDebugger, filename, info, thread = args exception, value, trace = arg if hasattr(mainDebugger, 'jinja2_exception_break') and mainDebugger.jinja2_exception_break: 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_frame, mainDebugger, thread, render_frame, CMD_ADD_EXCEPTION_BREAK) 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') or name.startswith('block '): #Jinja2 translates exception info and creates fake frame on his own pydb_frame.setSuspend(thread, CMD_ADD_EXCEPTION_BREAK) add_exception_to_frame(frame, (exception, value, trace)) thread.additionalInfo.suspend_type = JINJA2_SUSPEND flag = True return (flag, frame) return None
def exception_break(plugin, mainDebugger, pydb_frame, frame, args, arg): mainDebugger, filename, info, thread = args exception, value, trace = arg if mainDebugger.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(mainDebugger, thread, render_frame, CMD_ADD_EXCEPTION_BREAK) if suspend_frame: add_exception_to_frame(suspend_frame, (exception, value, trace)) flag = True thread.additionalInfo.message = 'VariableDoesNotExist' suspend_frame.f_back = frame frame = suspend_frame return (flag, frame) return None
def should_stop_on_exception(self, frame, event, arg): mainDebugger, _filename, info, thread = self._args flag = False if info.pydev_state != STATE_SUSPEND: #and breakpoint is not None: exception, value, trace = arg if trace is not None: #on jython trace is None on the first event exception_breakpoint = get_exception_breakpoint( exception, mainDebugger.break_on_caught_exceptions) if exception_breakpoint is not None: if not exception_breakpoint.notify_on_first_raise_only or just_raised( trace): # print frame.f_code.co_name add_exception_to_frame(frame, (exception, value, trace)) thread.additionalInfo.message = exception_breakpoint.qname flag = True else: flag = False else: try: if mainDebugger.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( self, mainDebugger, thread, render_frame, CMD_ADD_DJANGO_EXCEPTION_BREAK) if suspend_frame: add_exception_to_frame( suspend_frame, (exception, value, trace)) flag = True thread.additionalInfo.message = 'VariableDoesNotExist' suspend_frame.f_back = frame frame = suspend_frame except: flag = False return flag, frame
def should_stop_on_exception(self, frame, event, arg): mainDebugger, _filename, info, thread = self._args flag = False if info.pydev_state != STATE_SUSPEND: #and breakpoint is not None: exception, value, trace = arg if trace is not None: #on jython trace is None on the first event exception_breakpoint = get_exception_breakpoint( exception, mainDebugger.break_on_caught_exceptions) if exception_breakpoint is not None: if not exception_breakpoint.notify_on_first_raise_only or just_raised(trace): # print frame.f_code.co_name add_exception_to_frame(frame, (exception, value, trace)) thread.additionalInfo.message = exception_breakpoint.qname flag = True else: flag = False else: try: if mainDebugger.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( self, mainDebugger, thread, render_frame, CMD_ADD_DJANGO_EXCEPTION_BREAK) if suspend_frame: add_exception_to_frame(suspend_frame, (exception, value, trace)) flag = True thread.additionalInfo.message = 'VariableDoesNotExist' suspend_frame.f_back = frame frame = suspend_frame except : flag = False return flag, frame