You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
parameter_check_1 <- function(error) {
if (error){
stop()
}
}
tryCatchLog(parameter_check_1(error = TRUE),
error = function(e){} , # do nothing - in tryCatch this would suppress the error message according to https://stackoverflow.com/a/48831338/7219311
write.error.dump.file = getOption("tryCatchLog.write.error.dump.file", FALSE),
silent.warnings = getOption("tryCatchLog.silent.warnings", FALSE),
silent.messages = getOption("tryCatchLog.silent.messages", FALSE))
It would be helpful to add a silent.errors option.
The text was updated successfully, but these errors were encountered:
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").
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.
The text was updated successfully, but these errors were encountered: