mirror of https://github.com/CIRCL/lookyloo
fix: Catch exception when getting redirects on broken capture
parent
ecf58b512d
commit
63ba82dd0e
|
@ -127,19 +127,25 @@ class CaptureRedirects(Resource):
|
||||||
if not cache:
|
if not cache:
|
||||||
return {'error': 'UUID missing in cache, try again later and check the status first.'}, 400
|
return {'error': 'UUID missing in cache, try again later and check the status first.'}, 400
|
||||||
|
|
||||||
to_return: Dict[str, Any] = {'response': {'url': cache.url, 'redirects': []}}
|
to_return: Dict[str, Any] = {}
|
||||||
if not cache.redirects:
|
try:
|
||||||
to_return['response']['info'] = 'No redirects'
|
to_return = {'response': {'url': cache.url, 'redirects': []}}
|
||||||
return to_return
|
if not cache.redirects:
|
||||||
if cache.incomplete_redirects:
|
to_return['response']['info'] = 'No redirects'
|
||||||
# Trigger tree build, get all redirects
|
return to_return
|
||||||
lookyloo.get_crawled_tree(capture_uuid)
|
if cache.incomplete_redirects:
|
||||||
cache = lookyloo.capture_cache(capture_uuid)
|
# Trigger tree build, get all redirects
|
||||||
if cache:
|
lookyloo.get_crawled_tree(capture_uuid)
|
||||||
|
cache = lookyloo.capture_cache(capture_uuid)
|
||||||
|
if cache:
|
||||||
|
to_return['response']['redirects'] = cache.redirects
|
||||||
|
else:
|
||||||
to_return['response']['redirects'] = cache.redirects
|
to_return['response']['redirects'] = cache.redirects
|
||||||
else:
|
except Exception as e:
|
||||||
to_return['response']['redirects'] = cache.redirects
|
if cache and hasattr(cache, 'error'):
|
||||||
|
to_return['error'] = cache.error
|
||||||
|
else:
|
||||||
|
to_return['error'] = str(e)
|
||||||
return to_return
|
return to_return
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue