error() is similar to
stop(), but it also writes the error to a log file.
Whether it is shown, or written to the log, depends on the level and type of the error.
See details below for more information.
1 2 3 4 5 6 7
(strings) error to be displayed or written to file.
(integer, optional) The level of the error, from 1 to 10. Default: 1.
(integer, optional) The maximum level of messages to output. Default: set
in the option
(character, optional) The type to write or display. Must either NULL or one
or more from "INFO", "WARNING" or "ERROR". Default: set in the option
(string, optional) The file path to the text log file. If set to "", then no
logs are written. Default: set in the option
Whether an error is shown, or written to the log, depends on two options:
Level: This allows control over the depth of messages. Each message can be assigned a
level and if it is below the
msg_level (set in the package option
default) the message is displayed and written to the log.
Type: The type is refers to whether the message is "INFO", "WARNING" or "ERROR", as
produced by the functions
error() respectively. If the message
type is in the
msg_types (set in the package option
msgr.types by default) the
message is displayed and written to the log. This allows you to for instance, just
display errors and warnings and ignore messages.
The location of the log file is set in the package option
msgr.log_path, or as an argument to
this function. messages are added with a time stamp. If the
log_path is equal to "" then no
log is produced.
A string is return invisibly containing the error
1 2 3 4 5 6 7 8 9 10
## Not run: # Use error() to create timed errors error("This is a simple error") error("This is a level 2 error, so not shown by default", level = 2) # Set default level in options to determine what is shown options(msgr.level = 2) error("This is a level 2 error, so is shown now", level = 2) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.