% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/stop.r
\name{stop2}
\alias{stop2}
\alias{warning2}
\title{Display Warnings and Errors with Call Information}
\usage{
stop2(..., call. = TRUE, domain = NULL)

warning2(..., call. = TRUE, domain = NULL)
}
\arguments{
\item{...}{zero or more objects which can be coerced to
character (and which are pasted together with no separator).}

\item{call.}{call, logical, integer, or environment. logical, indicating
if the calling call should become part of the error message with same
semantics as \link{stop}. integer, specifying how many calls to go 'up'
the call stack to extract a call for the message. A value of
\code{0} will give the call to \code{stop2()} itself, \code{1} will give the
call of the caller, and so on. Numeric values are coerced to integer
and absolute values are taken. Values outside either boundary of the
call stack will be clamped to the nearest boundary. environment,
which will be matched against the calling stack and the corresponding
call will be shown.}

\item{domain}{see \link{gettext}. If \code{NA}, messages will not be translated.}
}
\value{
Called for side effects only.
}
\description{
Wrappers around \link{stop} and \link{warning} that
enable the \code{call.} argument to derive a call from the
stack.
}
\details{
These functions derive a call to be displayed and then construct
their own 'simple' conditions using \link{simpleError} and \link{simpleWarning}.

If a condition object is given as the first argument, it will be
treated in the same way as the base functions do, by warning that
other arguments will be ignored and then signalling the condition.

See \link{stop} and \link{warning} for full details.
}
\examples{
f1 <- function(call.) stop2("error", call. = call.)
f2 <- function(call.) f1(call. = call.)
f <- function(call.) f2(call. = call.)

try(f(call. = FALSE))
try(f(call. = TRUE))

try(f(call. = 0))
try(f(call. = 1))
try(f(call. = 2))

f <- function() {
  e <- environment()
  f1(call. = e)
}

try(f())

f1 <- function(call.) warning2("warning", call. = call.)
try(f())
}
\seealso{
\link{stopifnot2} and \link{stopifnot.with} for validations with
call information.
}
