Skip to content

Commit 6b79347

Browse files
more error handling
1 parent cdb803b commit 6b79347

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

webcap/browser.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,13 @@ async def screenshot_urls(self, urls):
121121
async def screenshot(self, url):
122122
try:
123123
tab = await self.new_tab(url)
124-
return await tab.screenshot()
124+
await tab.screenshot()
125+
return tab.webscreenshot
125126
except asyncio.TimeoutError:
126127
self.log.info(f"URL {url} load timed out after {self.timeout} seconds")
128+
raise
127129
except Exception as e:
128-
self.log.error(f"Error taking screenshot for {url}: {e}")
130+
self.log.error(f"Error visiting {url}: {e}")
129131
raise
130132
finally:
131133
with suppress(Exception):
@@ -134,7 +136,8 @@ async def screenshot(self, url):
134136
async def new_tab(self, url):
135137
tab = Tab(self)
136138
await tab.create()
137-
return await asyncio.wait_for(tab.navigate(url), timeout=self.timeout)
139+
await asyncio.wait_for(tab.navigate(url), timeout=self.timeout)
140+
return tab
138141

139142
async def start(self):
140143
await self.detect_chrome_path()

0 commit comments

Comments
 (0)