Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# webshot2 (development version)

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

# webshot2 0.1.1

* `webshot()` now supports JPEG (`.jpg` or `.jpeg`) and WEBP (`.webp`) image formats. (@trafficonese #45)
Expand Down
9 changes: 8 additions & 1 deletion R/webshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ new_session_screenshot <- function(


s <- NULL
err <- NULL

p <- chromote$new_session(wait_ = FALSE,
width = vwidth,
Expand Down Expand Up @@ -296,8 +297,14 @@ new_session_screenshot <- function(
if (!isTRUE(quiet)) message(url, " screenshot completed")
normalizePath(value)
})$
catch(function(err) {
err <<- err
})$
finally(function() {
s$close()
# Close down the session if we successfully started one
if (!is.null(s)) s$close()
# Or rethrow the error if we caught one
if (!is.null(err)) signalCondition(err)
})

p
Expand Down