mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +01:00
warc refactor: ArchiveLoadFailed no longer derived from WbException
catch separately, set status to 503 Archive Not Available explicitly
This commit is contained in:
parent
2b3fde028f
commit
4a94699a65
@ -7,7 +7,7 @@ from pywb.utils.statusandheaders import StatusAndHeadersParserException
|
|||||||
from pywb.utils.limitreader import LimitReader
|
from pywb.utils.limitreader import LimitReader
|
||||||
from pywb.utils.loaders import to_native_str
|
from pywb.utils.loaders import to_native_str
|
||||||
|
|
||||||
from pywb.utils.wbexception import WbException
|
#from pywb.utils.wbexception import WbException
|
||||||
from pywb.utils.timeutils import timestamp_to_iso_date
|
from pywb.utils.timeutils import timestamp_to_iso_date
|
||||||
|
|
||||||
from six.moves import zip
|
from six.moves import zip
|
||||||
@ -27,7 +27,7 @@ class ArcWarcRecord(object):
|
|||||||
|
|
||||||
|
|
||||||
#=================================================================
|
#=================================================================
|
||||||
class ArchiveLoadFailed(WbException):
|
class ArchiveLoadFailed(Exception):
|
||||||
def __init__(self, reason, filename=''):
|
def __init__(self, reason, filename=''):
|
||||||
if filename:
|
if filename:
|
||||||
msg = filename + ': ' + str(reason)
|
msg = filename + ': ' + str(reason)
|
||||||
@ -35,9 +35,7 @@ class ArchiveLoadFailed(WbException):
|
|||||||
msg = str(reason)
|
msg = str(reason)
|
||||||
|
|
||||||
super(ArchiveLoadFailed, self).__init__(msg)
|
super(ArchiveLoadFailed, self).__init__(msg)
|
||||||
|
self.msg = msg
|
||||||
def status(self):
|
|
||||||
return '503 Service Unavailable'
|
|
||||||
|
|
||||||
|
|
||||||
#=================================================================
|
#=================================================================
|
||||||
|
@ -107,7 +107,11 @@ class ResAggApp(object):
|
|||||||
if self.debug:
|
if self.debug:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
status = last_exc.status()
|
if not hasattr(last_exc, 'status'):
|
||||||
|
status = '503 Archive Not Available'
|
||||||
|
else:
|
||||||
|
status = last_exc.status()
|
||||||
|
|
||||||
message = last_exc.msg
|
message = last_exc.msg
|
||||||
|
|
||||||
res = {'message': message}
|
res = {'message': message}
|
||||||
|
@ -2,6 +2,7 @@ from pywb.webagg.responseloader import WARCPathLoader, LiveWebLoader, VideoLoad
|
|||||||
from pywb.webagg.utils import MementoUtils
|
from pywb.webagg.utils import MementoUtils
|
||||||
from pywb.utils.wbexception import BadRequestException, WbException
|
from pywb.utils.wbexception import BadRequestException, WbException
|
||||||
from pywb.utils.wbexception import NotFoundException
|
from pywb.utils.wbexception import NotFoundException
|
||||||
|
from pywb.warc.recordloader import ArchiveLoadFailed
|
||||||
|
|
||||||
from pywb.cdx.query import CDXQuery
|
from pywb.cdx.query import CDXQuery
|
||||||
from pywb.cdx.cdxdomainspecific import load_domain_specific_cdx_rules
|
from pywb.cdx.cdxdomainspecific import load_domain_specific_cdx_rules
|
||||||
@ -151,7 +152,7 @@ class ResourceHandler(IndexHandler):
|
|||||||
out_headers, resp = loader(cdx, params)
|
out_headers, resp = loader(cdx, params)
|
||||||
if resp is not None:
|
if resp is not None:
|
||||||
return out_headers, resp, errs
|
return out_headers, resp, errs
|
||||||
except WbException as e:
|
except (WbException, ArchiveLoadFailed) as e:
|
||||||
last_exc = e
|
last_exc = e
|
||||||
errs[str(loader)] = str(e)
|
errs[str(loader)] = str(e)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user