title: How to respect .call = FALSE in stop within sub function in R
body: <p>This is a simple question about how to provide clean error messages from sub functions in R.</p>
  
  <p>Usually, adding <code>call. = FALSE</code> to <code>stop</code> will not show the surrounding code to the user when it displays an error message from a function:</p>
  
  <pre><code>sub_function &lt;- function() {
    please &lt;- "don't show this code"
    stop("testing stop call equals false", call. = FALSE) 
  }
  sub_function()
  
  Error: testing stop call equals false
  Called from: sub_function()
  </code></pre>
  
  <p>However, if you put it inside another function can call it with <code>mapply</code>, it will not respect that setting:</p>
  
  <pre><code>stop_test &lt;- function(pkgs) {
    sub_function &lt;- function(pkg_name) {
    please &lt;- "don't show this code"
    if (pkg_name == "ahah!") stop("testing stop call equals false", call. = FALSE) 
    }
    mapply(sub_function, pkgs)
  }
  stop_test(c("dplyr", "ahah!"))
  
  Error: testing stop call equals false
  Called from: (function (pkg_name) 
  {
    please &lt;- "don't show this code"
    if (pkg_name == "ahah!") 
      stop("testing stop call equals false", call. = FALSE)
  })(dots[[1L]][[2L]])
  </code></pre>
  
  <p>How can I get R to only display my error message from sub function calls like this second example?</p>