def attach_ignore_from_exception(report, context): """Set the ignore key to True if the excception is ignored.""" info = context.get('exc_info') if info is None: return # Because of IUnloggedException being a sidewards lookup we must # capture this here to filter on later. report['ignore'] = IUnloggedException.providedBy(info[1])
def test_value_errors_marked(self): # When a ValueError is raised by the wrapped converter, the exception # is marked with IUnloggedException so the OOPS machinery knows that a # report should not be logged. converter = browser.get_converter('int') try: converter('not an int') except ValueError as e: self.assertTrue(IUnloggedException.providedBy(e))
def test_other_errors_not_marked(self): # When an exception other than ValueError is raised by the wrapped # converter, the exception is not marked with IUnloggedException an # OOPS report will be created. class BadString: def __str__(self): raise RuntimeError converter = browser.get_converter('string') try: converter(BadString()) except RuntimeError as e: self.assertFalse(IUnloggedException.providedBy(e))
def test_other_errors_not_marked(self): # When an exception other than ValueError is raised by the wrapped # converter, the exception is not marked with IUnloggedException an # OOPS report will be created. class FauxZopePublisherBrowserModule: def get_converter(self, type_): def the_converter(value): raise RuntimeError return the_converter module = FauxZopePublisherBrowserModule() customize_get_converter(module) converter = module.get_converter('int') try: converter(42) except RuntimeError as e: self.assertFalse(IUnloggedException.providedBy(e))
def test_value_errors_marked(self): # When a ValueError is raised by the wrapped converter, the exception # is marked with IUnloggedException so the OOPS machinery knows that a # report should not be logged. class FauxZopePublisherBrowserModule: def get_converter(self, type_): def the_converter(value): raise ValueError return the_converter module = FauxZopePublisherBrowserModule() customize_get_converter(module) converter = module.get_converter('int') try: converter(42) except ValueError as e: self.assertTrue(IUnloggedException.providedBy(e))