beep_on_error: Play a short sound if there is an error

Description Usage Arguments Details Examples

View source: R/beepr.R

Description

beep_on_error wraps an expression and plays a short sound only if an error occurs.

Usage

1
beep_on_error(expr, sound = 1)

Arguments

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:

  1. "ping"

  2. "coin"

  3. "fanfare"

  4. "complete"

  5. "treasure"

  6. "ready"

  7. "shotgun"

  8. "mario"

  9. "wilhelm"

  10. "facebook"

  11. "sword"

If sound does not match any of the sounds above, or is a valid path or url, a random sound will be played. Currently beep can only handle http urls, https is not supported.

Details

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.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# 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)

rasmusab/beepr documentation built on July 11, 2019, 8:47 p.m.