Add Classed error conditions for programmatic error handling#7139
Add Classed error conditions for programmatic error handling#7139MichaelChirico merged 25 commits intomasterfrom
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #7139 +/- ##
==========================================
+ Coverage 98.51% 98.77% +0.26%
==========================================
Files 81 81
Lines 15013 15197 +184
==========================================
+ Hits 14790 15011 +221
+ Misses 223 186 -37 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Generated via commit 5be1427 Download link for the artifact containing the test results: ↓ atime-results.zip
|
MichaelChirico
left a comment
There was a problem hiding this comment.
Thanks, this is a great start! cc @tdhock and @jangorecki, it will be good to have extra eyes here :)
|
the names are reasonable. |
Is this PR supposed to contain the |
|
yes, it was supposed to contain the dt_missing_argument_error class. I was going to use this in stopf("A non-empty vector of column names is required for |
|
I've added the script for checking error type condition class as of now. Can you please review. |
man/datatable-condition-classes.Rd
Outdated
| } | ||
| \seealso{ | ||
| \code{\link{data.table}}, \code{\link{setkey}}, \code{\link{merge.data.table}}, \code{\link{fintersect}}, \code{\link{funion}}, \code{\link{fsetdiff}} | ||
| \code{\link{tryCatch}}, \url{https://adv-r.hadley.nz/conditions.html} |
There was a problem hiding this comment.
While this reference is not bad, it unnecessarily uses third party packages. If there is an alternative that uses base R packages only, then I would prefer to use that one.
There was a problem hiding this comment.
Would using ?warning and ?signalCondition be appropriate here?
There was a problem hiding this comment.
Haven't read them.
A decent stackoverflow topic. We have an internal helper for exception handling in data.table:
data.table/R/test.data.table.R
Line 435 in 2f0d12f
There was a problem hiding this comment.
It's a good idea to link our ?test, yes. I still think we'd be remiss to omit the Advanced R chapter, which is by now a standard reference here. We can add others too.
There was a problem hiding this comment.
What about the first edition of Advanced R? There are mentions of pryr, but all exercises can be done using only base R, I think, and none of the code snippets depend on rlang. (Yes, the link is http:, and https: won't work. Since it's not a redirect, R CMD check won't yell at us.)

Fixes #5913
This PR implements 4 strategic classed error conditions to enable programmatic error handling in data.table, these changes add specific error classes to the most common user-reported errors.
Problem:
Currently,
data.tableerrors can only be caught generically usingtryCatch(..., error = function(e) ...). This makes it difficult for users to:Solution:
Starting implementing with some of the high impact error classes
dt_missing_column_error- Missing column errors during key setting, joins, and subsettingdt_unsortable_type_error- Unsortable types in key operationsdt_join_type_mismatch_error- Type incompatibility in joins operationsdt_invalid_input_error- Input validation failures that break data pipelinesNow the plan is to add more classes based on user feedback.
@MichaelChirico @tdhock @jangorecki can you please review