Re: [Rd] capturing multiple warnings in tryCatch()

2021-12-03 Thread Fox, John
Dear Adrian, For consistency, you might want to put toreturn$value <- output$value inside of if (capture) {}. In any event, it makes sense for me to wait for the modified admisc::tryCatchWEM to find its way to CRAN rather than to maintain my own version of the function. Thanks for this, John

Re: [Rd] capturing multiple warnings in tryCatch()

2021-12-03 Thread Adrian Dușa
Dear John, The logical argument capture is already in production use by other packages, but I think this is easily solved by: if (!is.null(output$value) & output$visible) { if (capture) { toreturn$output <- capture.output(output$value) } toreturn$value <- output$value } so th

Re: [Rd] capturing multiple warnings in tryCatch()

2021-12-03 Thread Fox, John
Dear Adrian, Here's my slightly modified version of your function, which serves my purpose: --- snip --- tryCatchWEM <- function (expr, capture = TRUE) { toreturn <- list() output <- withVisible(withCallingHandlers( tryCatch(expr, error = function(e) {

Re: [Rd] capturing multiple warnings in tryCatch()

2021-12-03 Thread Fox, John
Dear Rui, Thanks for this. Simon referred to demo(error.catching), and Adrian's version returns the printed representation of the result along with messages. Best, John On 2021-12-03, 11:35 AM, "Rui Barradas" wrote: Hello, I remembered having seen a function tryCatch.W.E and after

Re: [Rd] capturing multiple warnings in tryCatch()

2021-12-03 Thread Adrian Dușa
On Fri, 3 Dec 2021 at 00:37, Fox, John wrote: > Dear Henrik, Simon, and Adrian, > > As it turns out Adrian's admisc::tryCatchWEM() *almost* does what I want, > which is both to capture all messages and the result of the expression > (rather than the visible representation of the result). I was ea

Re: [Rd] capturing multiple warnings in tryCatch()

2021-12-03 Thread Rui Barradas
Hello, I remembered having seen a function tryCatch.W.E and after an online search, found where. It was in a R-Help post and in demo(error.catching). The question by Marius Hofert [1] was answered, among others, by Martin Maechler [2] which included the function tryCatch.W.E. These posts ref

Re: [Rd] capturing multiple warnings in tryCatch()

2021-12-03 Thread Daniele Medri
Interesting exchange of ideas. A feature that should be included soon in the codebase to help in some use-cases -- eg. handling thousand database connections on {L,W}AN. Il Gio 2 Dic 2021, 23:38 Fox, John ha scritto: > Dear Henrik, Simon, and Adrian, > > As it turns out Adrian's admisc::tryC