Skip to content

Commit 760d29e

Browse files
Pass the error object to retain more helpful info about error source (#7445)
* Pass the error object to retain more helpful info about error source * no domain= * use stop() to avoid gettextf() * make test more "hermetic" * Regression test, NEWS
1 parent a014e38 commit 760d29e

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,8 @@ See [#2611](https://github.com/Rdatatable/data.table/issues/2611) for details. T
375375
376376
7. In rare situations a data.table object may lose its internal attribute that holds a self-reference. New helper function `.selfref.ok()` tests just that. It is only intended for technical use cases. See manual for examples.
377377
378+
8. Retain important information in the error message about the source of the error when `i=` fails, e.g. pointing to `charToDate()` failing in `DT[date_col == "20250101"]`, [#7444](https://github.com/Rdatatable/data.table/issues/7444). Thanks @jan-swissre for the report and @MichaelChirico for the fix.
379+
378380
## data.table [v1.17.8](https://github.com/Rdatatable/data.table/milestone/41) (6 July 2025)
379381
380382
1. Internal functions used to signal errors are now marked as non-returning, silencing a compiler warning about potentially unchecked allocation failure. Thanks to Prof. Brian D. Ripley for the report and @aitap for the fix, [#7070](https://github.com/Rdatatable/data.table/pull/7070).

R/data.table.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ replace_dot_alias = function(e) {
111111
)
112112
idx = regexpr(missing_obj_regex, err_str, perl=TRUE)
113113
if (idx == -1L)
114-
stopf("%s", err_str, domain=NA) # Don't use stopf() directly, since err_str might have '%', #6588
114+
stop(err) # Pass 'err' to retain call site data (#7444); beware also #6588
115115
start = attr(idx, "capture.start", exact=TRUE)[ , "obj_name"]
116116
used = substr(
117117
err_str,

inst/tests/tests.Rraw

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20800,7 +20800,8 @@ baz(x)
2080020800
test(2295.7, is.data.table(x))
2080120801

2080220802
# #6588: .checkTypos used to give arbitrary strings to stopf as the first argument
20803-
test(2296, d2[x %no such operator% 1], error = '%no such operator%')
20803+
DT = data.table(a = 1)
20804+
test(2296, DT[x %no such operator% 1], error = '%no such operator%')
2080420805

2080520806
# fix coercing integer/double for joins on multiple columns, #6602
2080620807
x = data.table(a=1L)
@@ -21870,3 +21871,8 @@ test(2346, data.table::fread(text = text), data.table(mary = rep("mary", 99), ha
2187021871
DT = data.table(a="a", grp=1L)
2187121872
i = c(1, 1, 1, NA, NA)
2187221873
test(2347, DT[i, .(result = all(is.na(grp) == is.na(a))), by = grp][,all(result)], options = list(datatable.optimize = 0))
21874+
21875+
# .checkTypos internal implementation not exposed for non-typo bug, #7444
21876+
DT = data.table(a = as.Date("2010-01-01"), b = 1L)
21877+
test(2348.1, tryCatch(DT[a == as.Date("20100101")], error=conditionCall)[[1L]], quote(charToDate))
21878+
test(2348.2, tryCatch(DT[a == as.Date("20100101") | b == 2L], error=conditionCall)[[1L]], quote(charToDate))

0 commit comments

Comments
 (0)