File: throw.R

package info (click to toggle)
r-cran-r.oo 1.21.0-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,796 kB
  • sloc: sh: 18; makefile: 2
file content (43 lines) | stat: -rw-r--r-- 557 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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")