tests/throw.R

message("TESTING: throw()...")

library("R.oo")

## Generate an error
ex <- tryCatch({
  stop("An error")
}, error = function(ex) {
  ex
})
print(ex)

## Re-throw the error
ex2 <- tryCatch({
  throw(ex)
}, error = function(ex) {
  ex
})
print(ex2)

stopifnot(identical(ex2, ex))


## Generate an Exception
ex <- tryCatch({
  throw("An error")
}, error = function(ex) {
  ex
})
print(ex)

## Re-throw the Exception
ex2 <- tryCatch({
  throw(ex)
}, error = function(ex) {
  ex
})
print(ex2)

stopifnot(identical(ex2, ex))


message("TESTING: throw()...DONE")

Try the R.oo package in your browser

Any scripts or data that you put into this service are public.

R.oo documentation built on Nov. 2, 2024, 1:07 a.m.