Skip to content

Commit

Permalink
Fix explanation call
Browse files Browse the repository at this point in the history
  • Loading branch information
richfitz committed Jul 15, 2024
1 parent 2d5ab13 commit 47a2d25
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@
^\.covrignore$
^\.github$
\.*gcov$
^.*\.Rproj$
^\.Rproj\.user$
13 changes: 9 additions & 4 deletions R/parse_error.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@ cnd_footer.odin_parse_error <- function(cnd, ...) {
src <- unlist(lapply(src, "[[", "str"))
context <- sprintf("%s| %s", gsub(" ", "\u00a0", format(line)), src)
}

code <- cnd$code
explain <- cli::format_inline(
"For more information, run {.run odin2::odin_error_explain(\"{code}\")}")

c(">" = "Context:", context,
"i" = "For more information, run `odin_error_explain(\"{code}\")'")
"i" = explain)
}


Expand Down Expand Up @@ -58,13 +63,13 @@ odin_error_explain <- function(code) {
## * We might send the user to the web page version

assert_scalar_character(code)
if (!grepl("^E[0-9]{4}$")) {
if (!grepl("^E[0-9]{4}$", code)) {
cli::cli_abort("Invalid code '{code}', should match 'Exxxx'",
arg = "code")
}
txt <- errors$code
txt <- errors[[code]]
if (is.null(txt)) {
cli::cli_error(
cli::cli_abort(
c("Error '{code}' is undocumented",
i = paste("If you were directed here from an error message, please",
"let us know (e.g., file an issue or send us a message)")),
Expand Down

0 comments on commit 47a2d25

Please sign in to comment.