From cf817ffe278d6ea018446939591c81eca51cdf38 Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Tue, 8 May 2018 18:17:45 +0800 Subject: [PATCH] add Source.on_exception event hook --- nvchecker/core.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nvchecker/core.py b/nvchecker/core.py index bb061a1..135c72e 100644 --- a/nvchecker/core.py +++ b/nvchecker/core.py @@ -170,7 +170,9 @@ class Source: for fu in asyncio.as_completed(futures): name, result = await fu if isinstance(result, Exception): - logger.error('unexpected error happened', name=name, exc_info=result) + logger.error('unexpected error happened', + name=name, exc_info=result) + self.on_exception(name, result) elif result is not None: self.print_version_update(name, result) @@ -191,6 +193,9 @@ class Source: def on_update(self, name, version, oldver): pass + def on_exception(self, name, exc): + pass + def __repr__(self): return '' % self.name