R Under development (unstable) (2024-10-31 r87283 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > message("TESTING: InternalErrorException...") TESTING: InternalErrorException... > > library("R.oo") Loading required package: R.methodsS3 R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help. R.oo v1.27.0 successfully loaded. See ?R.oo for help. Attaching package: 'R.oo' The following object is masked from 'package:R.methodsS3': throw The following objects are masked from 'package:methods': getClasses, getMethods The following objects are masked from 'package:base': attach, detach, load, save > > ex <- InternalErrorException("Hmm... I didn't expect this!") > print(ex) [2024-11-01 18:36:37.565549] InternalErrorException: Hmm... I didn't expect this! This error is likely to be due to an internal error. Do not forget to report that you are using R v4.5.0 on a x86_64-w64-mingw32 platform together with R.oo v1.27.0. at #03. Exception(...) - Exception() is in environment 'R.oo' at #02. extend(Exception(...), "InternalErrorException", .package = package) - extend() is in environment 'R.oo' at #01. InternalErrorException("Hmm... I didn't expect this!") - InternalErrorException() is in environment 'R.oo' > > ex2 <- InternalErrorException("Hmm... I didn't expect this!", package=R.oo) > print(ex2) [2024-11-01 18:36:37.600551] InternalErrorException: Hmm... I didn't expect this! This error is likely to be due to an internal error related to package R.oo v1.27.0. Please report this problem to the maintainer Henrik Bengtsson or the author Henrik Bengtsson of that package. Do not forget to report that you are using R v4.5.0 on a x86_64-w64-mingw32 platform together with R.oo v1.27.0. at #03. Exception(...) - Exception() is in environment 'R.oo' at #02. extend(Exception(...), "InternalErrorException", .package = package) - extend() is in environment 'R.oo' at #01. InternalErrorException("Hmm... I didn't expect this!", package = R.oo) - InternalErrorException() is in environment 'R.oo' > > ex3 <- InternalErrorException("Hmm... I didn't expect this!", package="R.oo") > print(ex3) [2024-11-01 18:36:37.625528] InternalErrorException: Hmm... I didn't expect this! This error is likely to be due to an internal error related to package R.oo v1.27.0. Please report this problem to the maintainer Henrik Bengtsson or the author Henrik Bengtsson of that package. Do not forget to report that you are using R v4.5.0 on a x86_64-w64-mingw32 platform together with R.oo v1.27.0. at #03. Exception(...) - Exception() is in environment 'R.oo' at #02. extend(Exception(...), "InternalErrorException", .package = package) - extend() is in environment 'R.oo' at #01. InternalErrorException("Hmm... I didn't expect this!", package = "R.oo") - InternalErrorException() is in environment 'R.oo' > > > myLog <- function(x, ...) { + if (!is.numeric(x)) { + throw(InternalErrorException("Argument 'x' to myLog() is not numeric: ", + mode(x), package=R.oo)) + } + log(x, ...) + } > > > myLog(2) [1] 0.6931472 > > ex <- NULL > tryCatch({ + myLog("a") + }, error= function(ex) { + ex <- Exception$getLastException() + }) > > message("TESTING: InternalErrorException...DONE") TESTING: InternalErrorException...DONE > > proc.time() user system elapsed 0.40 0.07 0.46