Skip to content

[Query] Inspect Exceptions of Functions

github-actions[bot] edited this page Nov 8, 2026 · 1 revision

Generated from 'wiki-query.ts' on 2026-11-08, 09:20:49 UTC (v2.17.4), do not edit directly.

Inspect Exceptions of Functions Query [overview]

Determine whether functions throw exceptions (known to flowR)
This query is requested with the type inspect-exception.
Run in the REPL: :query @inspect-exception [(<crit>;...)] <code | file://path>

With this query you can identify which functions in the code throw exceptions (known to flowR).

Using the following example code:

mayFail <- function(x) {
  if(x < 0) stop("Negative value!")
  else sqrt(x)
}
safeFail <- function(x) {
  tryCatch(
    mayFail(x),
    error = function(e) { NA }
  )
}

the following query returns the information for all identified function definitions whether they throw exceptions:

[ { "type": "inspect-exception" } ]

(This can be shortened to @inspect-exception when used with the REPL command :query).

Results (prettified and summarized):

Query: inspect-exception
  - Function 20 (1.12-4.1) throws exceptions:
      - Exception maybe thrown at id 11 "stop" (2.13-35, cds: true:2.3-3.14)
  - Function 40 (8.13-30) does not throw exceptions.
  - Function 44 (5.13-10.1) does not throw exceptions.

Show Detailed Results as Json

The analysis ran (including parsing and normalization and the query) within the generation environment.

The JSON contains the ids of the nodes in question (see the Interface wiki page).

{"inspect-exception":{".meta":{},"exceptions":{"20":[{"id":11,"cds":[{"id":18,"when":true}]}],"40":[],"44":[]}},".meta":{}}
Original Code
mayFail <- function(x) {
  if(x < 0) stop("Negative value!")
  else sqrt(x)
}
safeFail <- function(x) {
  tryCatch(
    mayFail(x),
    error = function(e) { NA }
  )
}
Implementation Details

The Inspect Exceptions of Functions Query is executed by executeExceptionQuery.

Clone this wiki locally

⌂ 换网址