EVOLUTION-MANAGER
Edit File: caller_arg.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Find the caller argument for error messages</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for caller_arg {rlang}"><tr><td>caller_arg {rlang}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Find the caller argument for error messages</h2> <h3>Description</h3> <p><code>caller_arg()</code> is a variant of <code>substitute()</code> or <code><a href="defusing-advanced.html">ensym()</a></code> for arguments that reference other arguments. Unlike <code>substitute()</code> which returns an expression, <code>caller_arg()</code> formats the expression as a single line string which can be included in error messages. </p> <ul> <li><p> When included in an error message, the resulting label should generally be formatted as argument, for instance using the <code>.arg</code> in the cli package. </p> </li> <li><p> Use <code style="white-space: pre;">@inheritParams rlang::args_error_context</code> to document an <code>arg</code> or <code>error_arg</code> argument that takes <code>error_arg()</code> as default. </p> </li></ul> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>arg</code></td> <td> <p>An argument name in the current function.</p> </td></tr> </table> <h3>Examples</h3> <pre> arg_checker <- function(x, arg = caller_arg(x), call = caller_env()) { cli::cli_abort("{.arg {arg}} must be a thingy.", arg = arg, call = call) } my_function <- function(my_arg) { arg_checker(my_arg) } try(my_function(NULL)) </pre> <hr /><div style="text-align: center;">[Package <em>rlang</em> version 1.0.6 <a href="00Index.html">Index</a>]</div> </body></html>