rlang (version 0.2.2)

abort: Signal an error, warning, or message

Description

These functions are equivalent to base functions base::stop(), base::warning() and base::message(), but the type argument makes it easy to create subclassed conditions. They also don't include call information by default. This saves you from typing call. = FALSE to make error messages cleaner within package functions.

Usage

abort(msg, type = NULL, call = FALSE)

warn(msg, type = NULL, call = FALSE)

inform(msg, type = NULL, call = FALSE)

Arguments

msg

A message to display.

type

Subclass of the condition to signal.

call

Whether to display the call. If a number n, the call is taken from the nth frame on the call stack.

Details

Like stop() and cnd_abort(), abort() signals a critical condition and interrupts execution by jumping to top level (see rst_abort()). Only a handler of the relevant type can prevent this jump by making another jump to a different target on the stack (see with_handlers()).

warn() and inform() both have the side effect of displaying a message. These messages will not be displayed if a handler transfers control. Transfer can be achieved by establishing an exiting handler that transfers control to with_handlers()). In this case, the current function stops and execution resumes at the point where handlers were established.

Since it is often desirable to continue normally after a message or warning, both warn() and inform() (and their base R equivalent) establish a muffle restart where handlers can jump to prevent the message from being displayed. Execution resumes normally after that. See rst_muffle() to jump to a muffling restart, and the muffle argument of inplace() for creating a muffling handler.