purely {chronicler} | R Documentation |
Capture all errors, warnings and messages.
Description
Capture all errors, warnings and messages.
Usage
purely(.f, strict = 2)
Arguments
.f |
A function to decorate. |
strict |
Controls if the decorated function should catch only errors (1), errors and warnings (2, the default) or errors, warnings and messages (3). |
Value
A function which returns a list. The first element of the list, '$value', is the result of the original function '.f' applied to its inputs. The second element, '$log' is 'NULL' in case everything goes well. In case of error/warning/message, '$value' is NA and '$log' holds the message. 'purely()' is used by 'record()' to allow the latter to handle errors.
Examples
purely(log)(10)
purely(log)(-10)
purely(log, strict = 1)(-10) # This produces a warning, so with strict = 1 nothing gets captured.
[Package chronicler version 0.2.2 Index]