diff options
author | Florian Bruhin <me@the-compiler.org> | 2020-12-19 22:55:50 +0100 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2020-12-19 22:55:50 +0100 |
commit | 76daa78da60d9781dd8506d37a39253ef6ec42ea (patch) | |
tree | 9d42e31dbe5cf8e0930cb0b0a855ec8d26b0e335 | |
parent | 2560f9774b5f31b833c2ebf84e17dc38b3083bc3 (diff) | |
download | qutebrowser-76daa78da60d9781dd8506d37a39253ef6ec42ea.tar.gz qutebrowser-76daa78da60d9781dd8506d37a39253ef6ec42ea.zip |
Simplify redirection exception hierarchy
-rw-r--r-- | qutebrowser/browser/webengine/interceptor.py | 8 | ||||
-rw-r--r-- | qutebrowser/extensions/interceptors.py | 13 |
2 files changed, 5 insertions, 16 deletions
diff --git a/qutebrowser/browser/webengine/interceptor.py b/qutebrowser/browser/webengine/interceptor.py index b27509552..54bc5623b 100644 --- a/qutebrowser/browser/webengine/interceptor.py +++ b/qutebrowser/browser/webengine/interceptor.py @@ -45,16 +45,14 @@ class WebEngineRequest(interceptors.Request): def redirect(self, url: QUrl) -> None: if self._redirected: - raise interceptors.RedirectFailedException( - "Request already redirected.") + raise interceptors.RedirectException("Request already redirected.") if self._webengine_info is None: - raise interceptors.RedirectFailedException( - "Request improperly initialized.") + raise interceptors.RedirectException("Request improperly initialized.") # Redirecting a request that contains payload data is not allowed. # To be safe, abort on any request not in a whitelist. if (self._webengine_info.requestMethod() not in self._WHITELISTED_REQUEST_METHODS): - raise interceptors.RedirectFailedException( + raise interceptors.RedirectException( "Request method does not support redirection.") self._webengine_info.redirect(url) self._redirected = True diff --git a/qutebrowser/extensions/interceptors.py b/qutebrowser/extensions/interceptors.py index fddeaabc9..9c50346d7 100644 --- a/qutebrowser/extensions/interceptors.py +++ b/qutebrowser/extensions/interceptors.py @@ -59,17 +59,9 @@ class ResourceType(enum.Enum): class RedirectException(Exception): - """Raised when there was an error with redirection.""" - - -class RedirectFailedException(RedirectException): """Raised when the request was invalid, or a request was already made.""" -class RedirectUnsupportedException(RedirectException): - """Raised when redirection is currently unsupported.""" - - @attr.s class Request: @@ -96,14 +88,13 @@ class Request: Only some types of requests can be successfully redirected. Improper use of this method can result in redirect loops. - This method will throw a RedirectFailedException if the request was not - possible. + This method will throw a RedirectException if the request was not possible. Args: url: The QUrl to try to redirect to. """ # Will be overridden if the backend supports redirection - raise RedirectUnsupportedException("Unsupported backend.") + raise NotImplementedError #: Type annotation for an interceptor function. |