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

prevent application of inline markup within rethrown messages #870

Merged
merged 4 commits into from
Jan 21, 2025

Conversation

simonpcouch
Copy link
Collaborator

@simonpcouch simonpcouch commented Dec 9, 2024

Closes #859.

Safeguards against mistakenly applying inline markup to driver messages when rethrowing based on the cli documentation.

@simonpcouch simonpcouch requested review from hadley and removed request for hadley December 9, 2024 16:54
also, inlines `msg` into `cli_abort()` rather than reverting to `abort()`, per https://cli.r-lib.org/reference/inline-markup.html?q=escape#escaping-and-
@simonpcouch simonpcouch changed the title prevent application of inline markup when rethrown messages fail to parse prevent application of inline markup within rethrown messages Dec 9, 2024
@simonpcouch simonpcouch requested a review from hadley December 9, 2024 17:38
Copy link
Collaborator Author

@simonpcouch simonpcouch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ready for review, @hadley!

@@ -162,7 +162,7 @@ random_name <- function(prefix = "") {
rethrow_database_error <- function(msg, call = trace_back()$call[[1]]) {
tryCatch(
res <- parse_database_error(msg),
error = function(e) cli::cli_abort(msg, call = call)
error = function(e) cli::cli_abort("{msg}", call = call)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My initial guess re: the OP was that this had been the source of the failure (i.e. parse_database_error() failed and then the error handling mishandled the message). Turns out it wasn't, but I brought this in line with cli's documentation + added a test in the process that felt worth keeping around.

@simonpcouch simonpcouch merged commit 49b70ea into main Jan 21, 2025
17 checks passed
@simonpcouch simonpcouch deleted the rethrow-859 branch January 21, 2025 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A failing query using DBI::dbGetQuery() yields a useless error message
2 participants