Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show a readable error message when there’s an error in a module #286

Open
klmr opened this issue Jun 30, 2022 · 0 comments
Open

Show a readable error message when there’s an error in a module #286

klmr opened this issue Jun 30, 2022 · 0 comments
Assignees

Comments

@klmr
Copy link
Owner

klmr commented Jun 30, 2022

Currently, box::use() assumes that any error raised inside it must come from ‘box’ itself, and the error message/traceback is completely useless for module developers if there was an error in the loaded module source code:

x.r

f = function () stop('nope')
f()

box::use(./x)
Error in box::use(./x) : nope

〉traceback()
12: stop(box_error(message, call = call, subclass = subclass))
11: rethrow(error, call)
10: value[[3L]](cond)
9: tryCatchOne(expr, names, parentenv, handlers[[1L]])
8: tryCatchList(expr, classes, parentenv, handlers)
7: tryCatch(expr, error = function(error) rethrow(error, call))
6: rethrow_on_error({
       spec = parse_spec(declaration, alias)
       info = find_mod(spec, caller)
       load_and_register(spec, info, caller)
   }, call = use_call)
5: (function (declaration, alias, caller, use_call)
   {
       if (identical(declaration, quote(expr = )) && identical(alias,
           ""))
           return()
       rethrow_on_error({
           spec = parse_spec(declaration, alias)
           info = find_mod(spec, caller)
           load_and_register(spec, info, caller)
       }, call = use_call)
   })(dots[[1L]][[1L]], dots[[2L]][[1L]], dots[[3L]][[1L]], use_call = dots[[4L]][[1L]])
4: mapply(FUN = f, ..., SIMPLIFY = FALSE)
3: Map(.f, ..., USE.NAMES = FALSE)
2: map(use_one, imports, aliases, list(caller), use_call = list(sys.call()))
1: box::use(./x)

Expected result

Something along these lines:

box::use(./x)
Error in box::use(./x) :
  Error in f() : nope

〉traceback()
3: stop("nope") at ./x.r#1
2: f() at ./x.r#2
1: box::use(./x)
@klmr klmr self-assigned this Jun 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant