Reputation: 1346
I'm using sendmailR in my R script to send notifications.
Sometimes notification fails with the following error:
Unknown SMTP code: 452
Error in if (code == lcode) { : argument is of length zero
Execution halts.
How can I handle such errors, so that even if notification fails the script runs on?
Upvotes: 1
Views: 1007
Reputation: 37879
Wrap the try
function around sendmail
(assuming you use sendmail
, if not then wrap it around the function or code that produces the error) this way:
try(sendmail(from,to,subject), silent=T)
You can set silent to FALSE
if you want the error message to appear but still continue with the process
Upvotes: 2