From c20e97d0706deae4199ead88e682aee4883d0e11 Mon Sep 17 00:00:00 2001 From: Laurent Bachelier Date: Thu, 5 Jun 2014 23:12:08 +0200 Subject: [PATCH] pastealacon: Can now use specialized Browser exception --- modules/pastealacon/browser.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/modules/pastealacon/browser.py b/modules/pastealacon/browser.py index b1355373..db0a9741 100644 --- a/modules/pastealacon/browser.py +++ b/modules/pastealacon/browser.py @@ -19,10 +19,10 @@ import re -import requests from weboob.capabilities.paste import BasePaste, PasteNotFound from weboob.tools.browser2.filters import CleanText, DateTime, Env, RawText, Regexp from weboob.tools.browser2.page import HTMLPage, ItemElement, method, PagesBrowser, URL +from weboob.tools.exceptions import BrowserHTTPNotFound class Spam(Exception): @@ -101,12 +101,8 @@ class PastealaconBrowser(PagesBrowser): """ try: return self.raw.open(id=_id).text - # TODO maybe have Browser2 raise a specialized exception - except requests.exceptions.HTTPError as e: - if e.response.status_code == requests.codes.not_found: - raise PasteNotFound() - else: - raise e + except BrowserHTTPNotFound: + raise PasteNotFound() def post_paste(self, paste, expiration=None): self.post.stay_or_go().post(paste, expiration=expiration)