stop_bdpg | R Documentation |
When stop() is called from code inside tzar emulation, it sometimes crashes abruptly without writing the error message to the console and with no clue about where the crash happened. This function writes the stop message to the console before calling stop. In addition, it looks at two different flags to see whether it should call browser() before calling stop().
stop_bdpg(msg = "Stopping...", browser_on = TRUE)
msg |
a character string containing the error message to be passed to the stop function |
browser_on |
boolean indicating whether to call the browser before calling stop; TRUE implies browser should be called when the function's logic says to call the browser and FALSE implies that a replacement string should be written to the console when the logic says to call the browser |
Printing the stop message before calling stop will cause the message to be printed twice when not under tzar emulation, however, that's not a big deal compared to not seeing the message at all under emulation.
The two flags that the function considers when deciding whether to call browser() are browse_on_crash and bdpg.emulating_tzar.
The function first looks to see if a variable called browse_on_crash is visible to it (e.g., has been defined as a global variable). If it exists, then whatever value it has determines whether browser() is called, i.e., if TRUE, then browser() is called and if FALSE, it's not called.
If browse_on_crash does not exist, then the function will check the global options list using the getOption() call to see if a flag has been set there called "bdpg.emulating_tzar". If it exists and is set to TRUE, then browser() will be called. If it exists and is set to FALSE or if it does not exist in the options list, then browser() will not be called.
There is also an argument called "browser_on" that will probably never be used except during testing of the function. It's meant to flag whether to actually call browser() when the flags say to do it or whether instead, it should write a replacement string indicating that this is where the browser would be called. This is just to make it easier to test the function's logic without having to interact with the browser.
No return value
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.