diff --git a/pywb/warc/recordloader.py b/pywb/warc/recordloader.py index 90af9496..64c4181f 100644 --- a/pywb/warc/recordloader.py +++ b/pywb/warc/recordloader.py @@ -7,7 +7,7 @@ from pywb.utils.statusandheaders import StatusAndHeadersParserException from pywb.utils.limitreader import LimitReader 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 six.moves import zip @@ -27,7 +27,7 @@ class ArcWarcRecord(object): #================================================================= -class ArchiveLoadFailed(WbException): +class ArchiveLoadFailed(Exception): def __init__(self, reason, filename=''): if filename: msg = filename + ': ' + str(reason) @@ -35,9 +35,7 @@ class ArchiveLoadFailed(WbException): msg = str(reason) super(ArchiveLoadFailed, self).__init__(msg) - - def status(self): - return '503 Service Unavailable' + self.msg = msg #================================================================= diff --git a/pywb/webagg/app.py b/pywb/webagg/app.py index 90aadc5f..c2368c57 100644 --- a/pywb/webagg/app.py +++ b/pywb/webagg/app.py @@ -107,7 +107,11 @@ class ResAggApp(object): if self.debug: 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 res = {'message': message} diff --git a/pywb/webagg/handlers.py b/pywb/webagg/handlers.py index 707a9c89..50a4362f 100644 --- a/pywb/webagg/handlers.py +++ b/pywb/webagg/handlers.py @@ -2,6 +2,7 @@ from pywb.webagg.responseloader import WARCPathLoader, LiveWebLoader, VideoLoad from pywb.webagg.utils import MementoUtils from pywb.utils.wbexception import BadRequestException, WbException from pywb.utils.wbexception import NotFoundException +from pywb.warc.recordloader import ArchiveLoadFailed from pywb.cdx.query import CDXQuery from pywb.cdx.cdxdomainspecific import load_domain_specific_cdx_rules @@ -151,7 +152,7 @@ class ResourceHandler(IndexHandler): out_headers, resp = loader(cdx, params) if resp is not None: return out_headers, resp, errs - except WbException as e: + except (WbException, ArchiveLoadFailed) as e: last_exc = e errs[str(loader)] = str(e)