pastealacon: Can now use specialized Browser exception
This commit is contained in:
parent
6e051c4b54
commit
c20e97d070
1 changed files with 3 additions and 7 deletions
|
|
@ -19,10 +19,10 @@
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import requests
|
|
||||||
from weboob.capabilities.paste import BasePaste, PasteNotFound
|
from weboob.capabilities.paste import BasePaste, PasteNotFound
|
||||||
from weboob.tools.browser2.filters import CleanText, DateTime, Env, RawText, Regexp
|
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.browser2.page import HTMLPage, ItemElement, method, PagesBrowser, URL
|
||||||
|
from weboob.tools.exceptions import BrowserHTTPNotFound
|
||||||
|
|
||||||
|
|
||||||
class Spam(Exception):
|
class Spam(Exception):
|
||||||
|
|
@ -101,12 +101,8 @@ class PastealaconBrowser(PagesBrowser):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
return self.raw.open(id=_id).text
|
return self.raw.open(id=_id).text
|
||||||
# TODO maybe have Browser2 raise a specialized exception
|
except BrowserHTTPNotFound:
|
||||||
except requests.exceptions.HTTPError as e:
|
raise PasteNotFound()
|
||||||
if e.response.status_code == requests.codes.not_found:
|
|
||||||
raise PasteNotFound()
|
|
||||||
else:
|
|
||||||
raise e
|
|
||||||
|
|
||||||
def post_paste(self, paste, expiration=None):
|
def post_paste(self, paste, expiration=None):
|
||||||
self.post.stay_or_go().post(paste, expiration=expiration)
|
self.post.stay_or_go().post(paste, expiration=expiration)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue