error: Create error-messages.

Description Usage Arguments Value

View source: R/error.R

Description

This function wraps around stop and str_wrap from the stringr-package, and is a minor helper with regard to including detailed error-messages in the code without to much fuzz. It's also possible to get a quoted result.

Usage

1
2
3
error(..., .argument = NULL, n = 1, fun_stack = TRUE,
  quoted = FALSE, width = 80, indent = 4, exdent = 4,
  call. = FALSE, domain = NULL)

Arguments

...

A collection of vectors or lists containing the stuff that first will be inserted into code_str and then given to stop. Any lists will (after a sanity-check) be split into separate vectors; and each vector will be transformed to its separate paragraph, which will be separated by a blank line. Note that any formatting (like special characters for line breaks or tabulators) will be ignored.

.argument

The name(s) of the argument(s) that triggered the error. The default value for this argument is NULL, which suppress this part of the message.

n

A non-negative integer that select which function to report the error for. The default value 1 selects the function from which error was called, whereas higher values goes further up the call-stack (useful when sanity-checking of arguments is taken care of by a separate helper-function). Use 0 to suppress information about the functions. generations to report.

fun_stack

Logical value, default TRUE, that decides if a presentation of the full call-stack from the top-level to the function specified by n. Note that this argument will be reset to FALSE if n is 0.

quoted

Logical value, default FALSE. This can be used to return a quoted version of the error.

width

The value to be given to the width argument of str_wrap. Default value 80.

indent

The value to be given to the indent argument of str_wrap. Default value 4.

exdent

The value to be given to the exdent argument of str_wrap. Default value 4.

call.

The value to be given to the call.-argument of stop: logical, indicating if the call should become part of the error message. The default value for this function is FALSE.

domain

The value to be given to the domain-argument of stop: see gettext. If NA, messages will not be translated. The default value of this argument is NULL.

Value

The effect of this function will be that the information given to the dotsMethods-argument will be presented by means of str_wrap and stop, with variations depending on the values given to the other arguments. Note that nothing will be done if no arguments are given to .... If the function is used in the global workspace (happens under the development phase when writing a new function), then an adjusted message will be given with regard to the effect of the arguments fun_stack and n. The argument quoted can be used to return a quoted expression of the error, which might be useful if one would like to figure out if several errors was triggered by faulty arguments.


LAJordanger/leanRcoding documentation built on Feb. 27, 2020, 4:42 p.m.