tryCatch in R [Software]
Hi mittyri,
❝ a <- system(command="hamburger", intern = T)
❝ },
❝ error = function(cond) {
❝ a <<- cond
❝ }
Thank you for the proposal.
It works with the hamburger example but not when I invoke gcc :
So given the difference in behaviour I have a feeling this is about stderr and stdout. My own understanding of these concepts is rudimentary, to say the least.
R must be listening on both channels, so to say. Need to play a little more around with the ">" and ">2" commandline switches.
❝ maybe I misunderstood your goal but won't
❝ tryCatch(
❝ a <- system(command="hamburger", intern = T)
❝ },
❝ error = function(cond) {
❝ a <<- cond
❝ }
❝ )
❝ work?
Thank you for the proposal.
It works with the hamburger example but not when I invoke gcc :
> tryCatch(
+ {
+ a <- system("gcc -O2 -Wall Tester301.c -o T301", intern=T)
+ },
+ error = function(cond) {
+ a <<- cond
+ }
+ )
cc1: fatal error: Tester301.c: No such file or directory
compilation terminated.
Warning message:
In system("gcc -O2 -Wall Tester301.c -o T301", intern = T) :
running command 'gcc -O2 -Wall Tester301.c -o T301' had status 1
> a
character(0)
attr(,"status")
[1] 1
So given the difference in behaviour I have a feeling this is about stderr and stdout. My own understanding of these concepts is rudimentary, to say the least.
R must be listening on both channels, so to say. Need to play a little more around with the ">" and ">2" commandline switches.
—
Pass or fail!
ElMaestro
Pass or fail!
ElMaestro
Complete thread:
- system and system2 in R ElMaestro 2022-08-29 22:29 [Software]
- system and system2 in R Helmut 2022-08-30 01:10
- system and system2 in R ElMaestro 2022-08-30 08:52
- system and system2 in R Helmut 2022-08-30 11:25
- processx package mittyri 2022-08-31 17:50
- system and system2 in R ElMaestro 2022-08-30 08:52
- tryCatch in R mittyri 2022-08-31 17:53
- tryCatch in RElMaestro 2022-09-01 10:33
- tryCatch in R mittyri 2022-09-01 14:07
- tryCatch in RElMaestro 2022-09-01 10:33
- system and system2 in R Helmut 2022-08-30 01:10