Skip to content

Commit bf11200

Browse files
Copilotkrlmlr
andcommitted
Fix pluralization, "and" in zoomed tables, no parens for join methods
- abort_unknown_option: pluralize Option/Options, use commas(dquote()) without cli "and" for option lists - abort_table_not_zoomed: use {.code {zoomed_tables}} to get "and" before last item in zoomed tables list - abort_squash_limited: use {.code} instead of {.fn} for join method names (no parens: left_join not left_join()) - abort_apply_filters_first: same fix, {.code {join_name}} not {.fn} Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
1 parent 74a28ed commit bf11200

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

R/error-helpers.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,14 @@ abort_what_a_weird_object <- function(class) {
191191

192192
abort_squash_limited <- function() {
193193
cli::cli_abort(
194-
"{.code dm_flatten_to_tbl(.recursive = TRUE)} only supports join methods {.fn left_join}, {.fn inner_join}, {.fn full_join}.",
194+
"{.code dm_flatten_to_tbl(.recursive = TRUE)} only supports join methods {.code left_join}, {.code inner_join}, {.code full_join}.",
195195
class = dm_error_full("squash_limited")
196196
)
197197
}
198198

199199
abort_apply_filters_first <- function(join_name) {
200200
cli::cli_abort(
201-
"{.fn dm_..._to_tbl} with join method {.fn {join_name}} generally wouldn't produce the correct result when filters are set. Please consider calling {.fn dm_apply_filters} first.",
201+
"{.fn dm_..._to_tbl} with join method {.code {join_name}} generally wouldn't produce the correct result when filters are set. Please consider calling {.fn dm_apply_filters} first.",
202202
class = dm_error_txt_apply_filters_first(join_name)
203203
)
204204
}
@@ -314,7 +314,7 @@ abort_no_table_provided <- function() {
314314

315315
abort_table_not_zoomed <- function(table_name, zoomed_tables) {
316316
cli::cli_abort(
317-
"In {.fn pull_tbl.dm_zoomed}: Table {.code {table_name}} not zoomed, zoomed tables: {commas(tick(zoomed_tables))}.",
317+
"In {.fn pull_tbl.dm_zoomed}: Table {.code {table_name}} not zoomed, zoomed tables: {.code {zoomed_tables}}.",
318318
class = dm_error_full("table_not_zoomed")
319319
)
320320
}

R/paste.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ dquote <- function(x) {
348348
abort_unknown_option <- function(options, all_options) {
349349
bad_options <- setdiff(options, all_options)
350350
cli::cli_abort(
351-
"Option unknown: {.val {bad_options}}. Must be one of {.val {all_options}}.",
351+
"{qty(length(bad_options))}Option{?s} unknown: {commas(dquote(bad_options))}. Must be one of {commas(dquote(all_options))}.",
352352
class = dm_error_full("unknown_option")
353353
)
354354
}

tests/testthat/_snaps/error-helpers.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,12 @@
137137
abort_squash_limited()
138138
Condition
139139
Error in `abort_squash_limited()`:
140-
! `dm_flatten_to_tbl(.recursive = TRUE)` only supports join methods `left_join()`, `inner_join()`, `full_join()`.
140+
! `dm_flatten_to_tbl(.recursive = TRUE)` only supports join methods `left_join`, `inner_join`, `full_join`.
141141
Code
142142
abort_apply_filters_first("join_tightly")
143143
Condition
144144
Error in `abort_apply_filters_first()`:
145-
! `dm_..._to_tbl()` with join method `join_tightly()` generally wouldn't produce the correct result when filters are set. Please consider calling `dm_apply_filters()` first.
145+
! `dm_..._to_tbl()` with join method `join_tightly` generally wouldn't produce the correct result when filters are set. Please consider calling `dm_apply_filters()` first.
146146
Code
147147
abort_no_flatten_with_nest_join()
148148
Condition
@@ -206,7 +206,7 @@
206206
abort_table_not_zoomed("blur", c("focus_1", "focus_2"))
207207
Condition
208208
Error in `abort_table_not_zoomed()`:
209-
! In `pull_tbl.dm_zoomed()`: Table `blur` not zoomed, zoomed tables: `focus_1`, `focus_2`.
209+
! In `pull_tbl.dm_zoomed()`: Table `blur` not zoomed, zoomed tables: `focus_1` and `focus_2`.
210210
Code
211211
abort_not_pulling_multiple_zoomed()
212212
Condition

tests/testthat/_snaps/paste.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@
312312
writeLines(conditionMessage(expect_error(dm_paste(dm(), options = c("bogus",
313313
"all", "mad")))))
314314
Output
315-
Option unknown: "bogus" and "mad". Must be one of "all", "tables", "keys", "select", and "color".
315+
Options unknown: "bogus", "mad". Must be one of "all", "tables", "keys", "select", "color".
316316

317317
# output 2
318318

0 commit comments

Comments
 (0)