Skip to content

Commit

Permalink
Use rlang::try_fetch() to display errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ashbythorpe committed Oct 25, 2023
1 parent e8014d8 commit 564c932
Showing 1 changed file with 64 additions and 34 deletions.
98 changes: 64 additions & 34 deletions inst/etc/checks.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,77 @@ library(wdman)

tries <- list()

tries$chrome <- tryCatch({
print("chrome")
tmp <- chrome(verbose = TRUE)
print(tmp$log())
tmp$stop()
tmp
}, error = function(e) {print(e$message); e})

tries$gecko <- tryCatch({
print("gecko")
tmp <- gecko(verbose = TRUE)
print(tmp$log())
tmp$stop()
tmp
}, error = function(e) {print(e$message); e})
tries$chrome <- rlang::try_fetch(
{
print("chrome")
tmp <- chrome(verbose = TRUE)
print(tmp$log())
tmp$stop()
tmp
},
error = function(e) {
print(e)
e
}
)

tries$phantomjs <- tryCatch({
print("phantomjs")
tmp <- phantomjs(verbose = TRUE)
print(tmp$log())
tmp$stop()
tmp
}, error = function(e) {print(e$message); e})
tries$gecko <- tryCatch(
{
print("gecko")
tmp <- gecko(verbose = TRUE)
print(tmp$log())
tmp$stop()
tmp
},
error = function(e) {
print(e$message)
e
}
)

if (Sys.info()[["sysname"]] == "Windows") {
tries$iedriver <- tryCatch({
print("iedriver")
tmp <- iedriver(verbose = TRUE)
tries$phantomjs <- tryCatch(
{
print("phantomjs")
tmp <- phantomjs(verbose = TRUE)
print(tmp$log())
tmp$stop()
tmp
}, error = function(e) {print(e$message); e})
},
error = function(e) {
print(e$message)
e
}
)

if (Sys.info()[["sysname"]] == "Windows") {
tries$iedriver <- tryCatch(
{
print("iedriver")
tmp <- iedriver(verbose = TRUE)
print(tmp$log())
tmp$stop()
tmp
},
error = function(e) {
print(e$message)
e
}
)
}

tries$selenium <- tryCatch({
print("selenium")
tmp <- selenium(verbose = TRUE)
print(tmp$log())
tmp$stop()
tmp
}, error = function(e) {print(e$message); e})
tries$selenium <- tryCatch(
{
print("selenium")
tmp <- selenium(verbose = TRUE)
print(tmp$log())
tmp$stop()
tmp
},
error = function(e) {
print(e$message)
e
}
)

errors <- sapply(tries, function(x) is(x, "simpleError"))
if (any(errors)) {
Expand Down

0 comments on commit 564c932

Please sign in to comment.