aryoda / tryCatchLog

R package for better error handling incl. logging with a full (!) stack trace incl. line numbers, post-mortem analysis and support for parallel processing
Other
73 stars 8 forks source link

simpleMessage cannot be muffled (error: No restart muffleMessage found) #75

Open aryoda opened 2 years ago

aryoda commented 2 years ago

In the current version 1.3.2 (and possibly older ones) some message conditions cannot be muffled but throw an error, eg.:

tryCatchLog(signalCondition(simpleMessage("You cannot muffle simple messages, only standard messages")), silent.messages = T)
# Error in invokeRestart("muffleMessage") : 
# no 'restart' 'muffleMessage' found

Compare: Standard messages can be muffled:

tryCatchLog(message("You cannot muffle simple messages, only standard messages"), silent.messages = T)
aryoda commented 2 years ago

First diagnoses:

invokeRestart should only be called if a restart with the name does really exist, eg. here:

https://github.com/aryoda/tryCatchLog/blob/f3fdebd8bc6cd3a867fa2283fbb5f00df0c34b08/R/tryCatchLog.R#L347

Use findRestart to check this before calling the restart (everywhere in tryCatchLog).

I think "muffle warnings" is also affected (restart not always found, eg. for simpleWarning).

See also: rlang::cnd_muffle