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

Convert C++ exceptions to R conditions #17

Closed
davidchall opened this issue Jun 25, 2022 · 2 comments · Fixed by #20
Closed

Convert C++ exceptions to R conditions #17

davidchall opened this issue Jun 25, 2022 · 2 comments · Fixed by #20
Labels
enhancement New feature or request

Comments

@davidchall
Copy link
Owner

When rendering template, catch inja.exception.render_error and convert to R condition using rlang::abort(). This condition can store the reason, the missing data variable, and the location (line no, char no). From this metadata, we can construct a very helpful error message.

@davidchall davidchall added the enhancement New feature or request label Jun 25, 2022
@davidchall
Copy link
Owner Author

davidchall commented Jun 29, 2022

Design:

  • In C++ code
    • try { ... } catch (const inja::InjaError& e) { ... }
    • extract metadata (type, message, line, column)
    • rethrow as R condition
  • In R code

Using original text and line/column metadata, we can print the line and highlight the point where the problem occurred.

@davidchall
Copy link
Owner Author

Related: pantor/inja#249

@davidchall davidchall changed the title Custom error class Convert C++ exceptions to R conditions Jul 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant