beakr is an unopinionated and minimalist web framework for developing and deploying web services with R. It is designed to make it as simple as possible for data scientists and engineerings to quickly write web applications, services, and APIs without worrying about lower-level details or high-level side-effects. In other words, beakr is made to be explicit,robust, and scalable – and the batteries are not included.
In a previous post, we looked at error handling in R with the tryCatch() function and how this could be used to write Java style try-catch-finally blocks. This time we’ll look at what can be done with the try() function and how we can easily process warning and error messages to take appropriate action when something goes wrong.
The R language definition section on Exception Handling describes a very few basics about exceptions in R but is of little use to anyone trying to write robust code that can recover gracefully in the face of errors. In fact, if you do a little searching you will find that quite a few people have read through the ?tryCatch documentation but come away just as confused as when they started. In this post we’ll try to clarify a few things and describe how R’s error handling functions can be used to write code that functions similarly to Java’s try-catch-finally construct.