Closed R2Python closed 2 years ago
Thanks for your valuable feed back to improve tryCatchLog
!
Could you please help me to understand your feature request more exactly?
it would be helpful to suppress error messages
Do you want to
a) suppress the logging of error messages or
b) suppress the thrown error without handling it (to continue the execution with the next command after tryCatchLog()
)? This is what your example code does.
Regarding a): There is already a similar open feature request (but only for warnings): #11
Regarding b): I guess tryCatchLog::tryLog()
could work then.
Historically in base R there is no "silent errors" argument in tryCatch()
because the reason to use this function is exactly
to catch (and handle) errors. If you do not want to catch and handle errors, base R provides try()
which does not throw an error but just returns an "error" object instead.
In tryCatchLog
I have kept this base R semantics and "just" added logging for easy understanding ("don't surprise the user with unexpected semantics").
There is no ways auf muffling ("silencing" in tryCatchLog
wording) an error
condition:
Errors are not mufflable since they are signalled in critical situations where execution cannot continue safely
Source: https://rlang.r-lib.org/reference/cnd_muffle.html
I am afraid I have to close this issue (subject to be reopened when base R should support this one day)...
In some situations, it would be helpful to suppress error messages. Examples include:
https://stackoverflow.com/questions/19111956/suppress-error-message-in-r https://stackoverflow.com/questions/70274274/r-errorhandling-with-trycatchlog-create-a-customizable-result-code-for-the-co
According to the documentation "Warnings and messages can be “silenced” (only logged but not propagated to the caller) using the silent.* parameters.", implying that errors can not be silenced.
There is also an option to create dump files in case of errors, but this is also not suppressing error messages. Thus, the following code is not suppressing error warnings:
It would be helpful to add a silent.errors option.