From 225e00abb71a361e1ff318fa7a25f7eff5eb1cc8 Mon Sep 17 00:00:00 2001 From: Kevin Lloyd Bernal Date: Fri, 25 Feb 2022 16:42:49 +0800 Subject: [PATCH 1/2] add ReloadResponseData exception --- web_poet/exceptions.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 web_poet/exceptions.py diff --git a/web_poet/exceptions.py b/web_poet/exceptions.py new file mode 100644 index 00000000..82ac22e0 --- /dev/null +++ b/web_poet/exceptions.py @@ -0,0 +1,13 @@ +class ReloadResponseData(Exception): + """Indicates that there's something wrong with :class:`~.ResponseData` and + it needs to be downloaded again. + + You should use this in instance where the HTTP Response is malformed, missing + some required information, etc. + + This should be raised inside the subclasses of :class:`~.WebPage` or anything + which requires :class:`~.ResponseData` as a dependency. The framework which + handles the Page Objects should then attempt to create a new instance with a + fresh :class:`~.ResponseData` dependency. + """ + pass From 4b8c44647d80e94d4ea1549746273ce426c3d47d Mon Sep 17 00:00:00 2001 From: Kevin Lloyd Bernal Date: Fri, 25 Feb 2022 17:05:17 +0800 Subject: [PATCH 2/2] add DelegateFallback exception --- web_poet/exceptions.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/web_poet/exceptions.py b/web_poet/exceptions.py index 82ac22e0..769cb017 100644 --- a/web_poet/exceptions.py +++ b/web_poet/exceptions.py @@ -10,4 +10,20 @@ class ReloadResponseData(Exception): handles the Page Objects should then attempt to create a new instance with a fresh :class:`~.ResponseData` dependency. """ + + pass + + +class DelegateFallback(Exception): + """Indicates that the Page Object isn't able to perform data extractions on + a given page. + + This should be raised in cases wherein the page has unknown layouts, unsupported + data, etc. + + Raising this won't be a guarantee that a fallback parser for the page is + available. It would depend on the framework using the Page Object on how to + resolve the fallbacks. + """ + pass