beep_on_error {beepr} | R Documentation |
beep_on_error
wraps an expression and plays a short sound only if an
error occurs.
beep_on_error(expr, sound = 1)
expr |
An expression to be evaluated for errors. |
sound |
character string or number specifying what sound to be played by either specifying one of the built in sounds, specifying the path to a wav file or specifying an url. The default is 1. Possible sounds are:
If |
If beep
is not able to play the sound a warning is issued rather than
an error. This is in order to not risk aborting or stopping the process that
you wanted to get notified about.
# Play a "ping" sound if \code{expr} produces an error
beep_on_error(log("foo"))
# Stay silent if \code{expr} does not produce an error
beep_on_error(log(1))
## Not run:
# Play the Wilhelm scream instead of a ping on error.
beep_on_error(runif("bar"), "wilhelm")
## End(Not run)