Skip to content

Commit 6dbc414

Browse files
remove unwanted changes
1 parent 3a8f73e commit 6dbc414

File tree

5 files changed

+10
-54
lines changed

5 files changed

+10
-54
lines changed

R/groupingsets.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ rollup = function(x, ...) {
44
rollup.data.table = function(x, j, by, .SDcols, id = FALSE, label = NULL, ...) {
55
# input data type basic validation
66
if (!is.data.table(x))
7-
stopf("Argument 'x' must be a data.table object", class="dt_invalid_input_error")
7+
stopf("Argument 'x' must be a data.table object")
88
if (!is.character(by))
99
stopf("Argument 'by' must be a character vector of column names used in grouping.")
1010
if (!is.logical(id))
@@ -22,7 +22,7 @@ cube = function(x, ...) {
2222
cube.data.table = function(x, j, by, .SDcols, id = FALSE, label = NULL, ...) {
2323
# input data type basic validation
2424
if (!is.data.table(x))
25-
stopf("Argument 'x' must be a data.table object", class="dt_invalid_input_error")
25+
stopf("Argument 'x' must be a data.table object")
2626
if (!is.character(by))
2727
stopf("Argument 'by' must be a character vector of column names used in grouping.")
2828
if (!is.logical(id))

R/merge.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ merge.data.table = function(x, y, by = NULL, by.x = NULL, by.y = NULL, all = FAL
3434
warningf("Supplied both `by` and `by.x`/`by.y`. `by` argument will be ignored.")
3535
if (!is.null(by.x)) {
3636
if (length(by.x) == 0L || !is.character(by.x) || !is.character(by.y))
37-
stopf("A non-empty vector of column names is required for `by.x` and `by.y`.", class="dt_invalid_input_error")
37+
stopf("A non-empty vector of column names is required for `by.x` and `by.y`.")
3838
if (!all(idx <- by.x %chin% nm_x)) {
3939
stopf("The following columns listed in `%s` are missing from %s: %s", "by.x", "x", brackify(by.x[!idx]))
4040
}

R/setkey.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ setkeyv = function(x, cols, verbose=getOption("datatable.verbose"), physical=TRU
4343
if (!all(nzchar(cols))) stopf("cols contains some blanks.")
4444
cols = gsub("`", "", cols, fixed = TRUE)
4545
miss = !(cols %chin% colnames(x))
46-
if (any(miss)) stopf("some columns are not in the data.table: %s", brackify(cols[miss]), class = "dt_missing_column_error")
46+
if (any(miss)) stopf("some columns are not in the data.table: %s", brackify(cols[miss]))
4747

4848
if (physical && identical(head(key(x), length(cols)), cols)){ ## for !physical we need to compute groups as well #4387
4949
## key is present but x has a longer key. No sorting needed, only attribute is changed to shorter key.
@@ -54,7 +54,7 @@ setkeyv = function(x, cols, verbose=getOption("datatable.verbose"), physical=TRU
5454
if (".xi" %chin% names(x)) stopf("x contains a column called '.xi'. Conflicts with internal use by data.table.")
5555
for (i in cols) {
5656
.xi = x[[i]] # [[ is copy on write, otherwise checking type would be copying each column
57-
if (!typeof(.xi) %chin% ORDERING_TYPES) stopf("Column '%s' is type '%s' which is not supported as a key column type, currently.", i, typeof(.xi), class="dt_unsortable_type_error")
57+
if (!typeof(.xi) %chin% ORDERING_TYPES) stopf("Column '%s' is type '%s' which is not supported as a key column type, currently.", i, typeof(.xi))
5858
}
5959
if (!is.character(cols) || length(cols)<1L) internal_error("'cols' should be character at this point") # nocov
6060

@@ -266,11 +266,11 @@ setorderv = function(x, cols = colnames(x), order=1L, na.last=FALSE)
266266
# remove backticks from cols
267267
cols = gsub("`", "", cols, fixed = TRUE)
268268
miss = !(cols %chin% colnames(x))
269-
if (any(miss)) stopf("some columns are not in the data.table: %s", brackify(cols[miss]), class = "dt_missing_column_error")
269+
if (any(miss)) stopf("some columns are not in the data.table: %s", brackify(cols[miss]))
270270
if (".xi" %chin% colnames(x)) stopf("x contains a column called '.xi'. Conflicts with internal use by data.table.")
271271
for (i in cols) {
272272
.xi = x[[i]] # [[ is copy on write, otherwise checking type would be copying each column
273-
if (!typeof(.xi) %chin% ORDERING_TYPES) stopf("Column '%s' is type '%s' which is not supported for ordering currently.", i, typeof(.xi), class="dt_unsortable_type_error")
273+
if (!typeof(.xi) %chin% ORDERING_TYPES) stopf("Column '%s' is type '%s' which is not supported for ordering currently.", i, typeof(.xi))
274274
}
275275
if (!is.character(cols) || length(cols)<1L) internal_error("'cols' should be character at this point") # nocov
276276

R/setops.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ setdiff_ = function(x, y, by.x=seq_along(x), by.y=seq_along(y), use.names=FALSE)
1414
icnam = names(y)[lc]
1515
xcnam = names(x)[rc]
1616
if ( is.character(x[[rc]]) && !(is.character(y[[lc]]) || is.factor(y[[lc]])) ) {
17-
stopf("When x's column ('%s') is character, the corresponding column in y ('%s') should be factor or character, but found incompatible type '%s'.", xcnam, icnam, typeof(y[[lc]]), class="dt_join_type_mismatch_error")
17+
stopf("When x's column ('%s') is character, the corresponding column in y ('%s') should be factor or character, but found incompatible type '%s'.", xcnam, icnam, typeof(y[[lc]]))
1818
} else if ( is.factor(x[[rc]]) && !(is.character(y[[lc]]) || is.factor(y[[lc]])) ) {
19-
stopf("When x's column ('%s') is factor, the corresponding column in y ('%s') should be character or factor, but found incompatible type '%s'.", xcnam, icnam, typeof(y[[lc]]), class="dt_join_type_mismatch_error")
19+
stopf("When x's column ('%s') is factor, the corresponding column in y ('%s') should be character or factor, but found incompatible type '%s'.", xcnam, icnam, typeof(y[[lc]]))
2020
} else if ( (is.integer(x[[rc]]) || is.double(x[[rc]])) && (is.logical(y[[lc]]) || is.character(y[[lc]])) ) {
21-
stopf("When x's column ('%s') is integer or numeric, the corresponding column in y ('%s') can not be character or logical types, but found incompatible type '%s'.", xcnam, icnam, typeof(y[[lc]]), class="dt_join_type_mismatch_error")
21+
stopf("When x's column ('%s') is integer or numeric, the corresponding column in y ('%s') can not be character or logical types, but found incompatible type '%s'.", xcnam, icnam, typeof(y[[lc]]))
2222
}
2323
}
2424
ux = unique(shallow(x, by.x))

vignettes/datatable-programming.Rmd

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -456,50 +456,6 @@ DT[, eval(cl)]
456456
DT[, cl, env = list(cl = cl)]
457457
```
458458

459-
## Error handling with classed conditions
460-
461-
Starting from version 1.17.0, `data.table` provides specific error classes for common operations, making it easier to handle errors programmatically. This is particularly useful when writing robust code or packages that use `data.table`.
462-
463-
### Available error classes
464-
465-
`data.table` now provides four specific error classes:
466-
467-
- `dt_missing_column_error`: When referencing columns that don't exist
468-
- `dt_invalid_input_error`: When providing invalid input types or empty required arguments
469-
- `dt_unsortable_type_error`: When trying to sort/key unsupported types
470-
- `dt_join_type_mismatch_error`: When column types are incompatible in joins/set operations
471-
472-
### Usage examples
473-
474-
```{r error_handling, error=TRUE}
475-
DT <- data.table(a = 1:3, b = 4:6)
476-
477-
# Handle missing column errors specifically
478-
tryCatch({
479-
setkey(DT, "nonexistent_col")
480-
}, dt_missing_column_error = function(e) {
481-
cat("Missing column detected:", conditionMessage(e), "\n")
482-
}, error = function(e) {
483-
cat("Other error:", conditionMessage(e), "\n")
484-
})
485-
486-
# Handle type mismatches in operations
487-
DT1 <- data.table(id = 1:3, value = c("a", "b", "c"))
488-
DT2 <- data.table(id = 1:3, value = 1:3)
489-
490-
tryCatch({
491-
fintersect(DT1, DT2)
492-
}, dt_join_type_mismatch_error = function(e) {
493-
cat("Type mismatch in join:", conditionMessage(e), "\n")
494-
}, error = function(e) {
495-
cat("Other error:", conditionMessage(e), "\n")
496-
})
497-
```
498-
499-
### Backward compatibility
500-
501-
All error classes inherit from base R's condition system, so existing `tryCatch(..., error = ...)` code continues to work unchanged. The new classes simply provide more specific handling options when needed.
502-
503459
```{r cleanup, echo=FALSE}
504460
options(.opts)
505461
registerS3method("print", "data.frame", base::print.data.frame)

0 commit comments

Comments
 (0)