summaryrefslogtreecommitdiff
path: root/crocoite
diff options
context:
space:
mode:
Diffstat (limited to 'crocoite')
-rw-r--r--crocoite/browser.py5
-rw-r--r--crocoite/cli.py5
-rw-r--r--crocoite/test_browser.py10
3 files changed, 12 insertions, 8 deletions
diff --git a/crocoite/browser.py b/crocoite/browser.py
index ce96f7e..10eaaff 100644
--- a/crocoite/browser.py
+++ b/crocoite/browser.py
@@ -269,6 +269,9 @@ class VarChangeEvent:
await self.event.wait ()
return self._value
+class NavigateError (IOError):
+ pass
+
class SiteLoader:
"""
Load site in Chrome and monitor network requests
@@ -364,6 +367,8 @@ class SiteLoader:
ret = await self.tab.Page.navigate(url=url)
self.logger.debug ('navigate',
uuid='9d47ded2-951f-4e09-86ee-fd4151e20666', result=ret)
+ if 'errorText' in ret:
+ raise NavigateError (ret['errorText'])
# internal chrome callbacks
async def _requestWillBeSent (self, **kwargs):
diff --git a/crocoite/cli.py b/crocoite/cli.py
index 0595eb9..fb9060d 100644
--- a/crocoite/cli.py
+++ b/crocoite/cli.py
@@ -32,7 +32,7 @@ try:
except ModuleNotFoundError:
pass
-from . import behavior
+from . import behavior, browser
from .controller import SinglePageController, \
ControllerSettings, StatsHandler, LogHandler, \
RecursiveController, DepthLimit, PrefixLimit
@@ -47,6 +47,7 @@ class SingleExitStatus(IntEnum):
Ok = 0
Fail = 1
BrowserCrash = 2
+ Navigate = 3
def single ():
parser = argparse.ArgumentParser(description='Save website to WARC using Google Chrome.')
@@ -90,6 +91,8 @@ def single ():
except asyncio.CancelledError:
# don’t log this one
pass
+ except browser.NavigateError:
+ ret = SingleExitStatus.Navigate
except Exception as e:
ret = SingleExitStatus.Fail
logger.error ('cli exception',
diff --git a/crocoite/test_browser.py b/crocoite/test_browser.py
index 7727259..6341bd6 100644
--- a/crocoite/test_browser.py
+++ b/crocoite/test_browser.py
@@ -34,7 +34,7 @@ import pytest
from .browser import RequestResponsePair, SiteLoader, VarChangeEvent, Request, \
UnicodeBody, ReferenceTimestamp, Base64Body, UnicodeBody, Request, \
- Response
+ Response, NavigateError
from .logger import Logger, Consumer
from .devtools import Crashed, Process
@@ -74,12 +74,8 @@ async def test_invalidurl (loader):
resolved = await loop.getaddrinfo (host, None)
except socket.gaierror:
url = URL.build (scheme='http', host=host)
- await loader.navigate (url)
- async for it in loader:
- assert it.request is not None
- assert it.url == url
- assert it.response is None
- break
+ with pytest.raises (NavigateError):
+ await loader.navigate (url)
else:
pytest.skip (f'host {host} resolved to {resolved}')