On Sun, 16 Apr 2023 at 12:58, nos...@altfeld-im.de <nos...@altfeld-im.de> wrote: > > I am the author of the *tryCatchLog* package and want to > > - suppress selected conditions (warnings and messages) > - rethrow selected conditions (e.g a specific warning as a message or to > "rename" the condition text). > > I could not find any reliable unique identifier for each possible condition > > - that (base) R throws > - that 3rd-party packages can throw (out of scope here). > > Is there any reliable way to identify each possible condition of base R?
I don't think so. As stated in the manual, "‘simpleError’ is the class used by ‘stop’ and all internal error signals". > Are there plans to implement such an identifier ("errno")? I agree that something like this would be a nice addition. With the current condition system, it would be certainly easy (but quite a lot of work) to define a hierarchy of built-in conditions, and then use them consistently throughout base R. For example, > 1 + "a" Error in 1 + "a" : non-numeric argument to binary operator could be a "typeError". And catching this is already possible: > e <- errorCondition("non-numeric argument to binary operator", > class="typeError") > tryCatch(stop(e), typeError=function(e) print("hello")) [1] "hello" -- Iñaki Úcar ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel