Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add core exceptions #26

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions web_poet/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class ReloadResponseData(Exception):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking of a way to indicate the maximum retry attempts in this exception.

However, it's best to leave that to the framework using web-poet to standardize limits, delays, etc.

"""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


class DelegateFallback(Exception):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be split into expected and unexpected fallback requests. One of them should trigger some sort of alerts or monitoring actions (e.g. unexpected layouts).

"""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