Skip to content

Commit ad5d887

Browse files
authored
fix(webshot): Rethrow underlying chromote errors (#69)
* fix(webshot): Rethrow underlying chromote errors * docs: Add news item
1 parent 37a4751 commit ad5d887

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# webshot2 (development version)
22

3+
* `webshot()` now surfaces errors that occur when working with the lower-level screenshot API provided by Chrome via `{chromote}`. (#69)
4+
35
# webshot2 0.1.1
46

57
* `webshot()` now supports JPEG (`.jpg` or `.jpeg`) and WEBP (`.webp`) image formats. (@trafficonese #45)

R/webshot.R

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ new_session_screenshot <- function(
251251

252252

253253
s <- NULL
254+
err <- NULL
254255

255256
p <- chromote$new_session(wait_ = FALSE,
256257
width = vwidth,
@@ -296,8 +297,14 @@ new_session_screenshot <- function(
296297
if (!isTRUE(quiet)) message(url, " screenshot completed")
297298
normalizePath(value)
298299
})$
300+
catch(function(err) {
301+
err <<- err
302+
})$
299303
finally(function() {
300-
s$close()
304+
# Close down the session if we successfully started one
305+
if (!is.null(s)) s$close()
306+
# Or rethrow the error if we caught one
307+
if (!is.null(err)) signalCondition(err)
301308
})
302309

303310
p

0 commit comments

Comments
 (0)