From ebenedito@ @ending from gm@il@com  Thu Nov 22 23:51:31 2018
From: ebenedito@ @ending from gm@il@com (Ernest Benedito)
Date: Thu, 22 Nov 2018 23:51:31 +0100
Subject: [Rd] [tryExcept] New try Function
Message-ID: <ADFC5C3F-9849-4AF3-86B0-017615152298@gmail.com>

Hi everyone,

When dealing with errors, sometimes I want to run a bunch of code when an error occurs.
For now I usually use a structure such as:

res <- tryCatch(expr, error = function(cond) cond) # or try(expr)

if (inherits(res, ?error?)) # or inherits(res, ?try-error?)
  # a bunch of code

I though it would be useful to have a function that does this naturally, so I came up with the attached function.

I would be glad to hear your insights and if you think it would make sense to add this function to R.

Best regards,
Ernest


[Rd] [tryExcept] New try Function
Ernest Benedito