Skip to content

Commit

Permalink
Remove error classes for now (#5280)
Browse files Browse the repository at this point in the history
Closes #5266
  • Loading branch information
lionel- authored May 28, 2020
1 parent 76f1df8 commit 2855355
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
20 changes: 4 additions & 16 deletions R/rows.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,7 @@ rows_insert.data.frame <- function(x, y, by = NULL, ..., copy = FALSE, in_place
idx <- vctrs::vec_match(y[key], x[key])
bad <- which(!is.na(idx))
if (has_length(bad)) {
abort(class = "dplyr_rows_insert_duplicate",
"Attempting to insert duplicate rows.",
location = bad
)
abort("Attempting to insert duplicate rows.")
}

rows_bind(x, y)
Expand All @@ -121,10 +118,7 @@ rows_update.data.frame <- function(x, y, by = NULL, ..., copy = FALSE, in_place

bad <- which(is.na(idx))
if (has_length(bad)) {
abort(class = "dplyr_rows_update_missing",
"Attempting to update missing rows.",
location = bad
)
abort("Attempting to update missing rows.")
}

x[idx, names(y)] <- y
Expand Down Expand Up @@ -152,10 +146,7 @@ rows_patch.data.frame <- function(x, y, by = NULL, ..., copy = FALSE, in_place =

bad <- which(is.na(idx))
if (has_length(bad)) {
abort(class = "dplyr_rows_patch_missing",
"Attempting to patch missing rows.",
location = bad
)
abort("Attempting to patch missing rows.")
}

new_data <- map2(x[idx, names(y)], y, coalesce)
Expand Down Expand Up @@ -219,10 +210,7 @@ rows_delete.data.frame <- function(x, y, by = NULL, ..., copy = FALSE, in_place

bad <- which(is.na(idx))
if (has_length(bad)) {
abort(class = "dplyr_rows_delete_missing",
"Attempting to delete missing rows.",
location = bad
)
abort("Attempting to delete missing rows.")
}

dplyr_row_slice(x, -idx)
Expand Down
10 changes: 5 additions & 5 deletions tests/testthat/test-rows.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test_that("rows_insert()", {

expect_error(
rows_insert(data, tibble(a = 3, b = "z")),
class = "dplyr_rows_insert_duplicate"
"insert duplicate"
)
})

Expand All @@ -22,7 +22,7 @@ test_that("rows_update()", {

expect_error(
rows_update(data, tibble(a = 2:3, b = "z"), by = c("a", "b")),
class = "dplyr_rows_update_missing"
"update missing"
)

expect_silent(
Expand All @@ -43,7 +43,7 @@ test_that("rows_patch()", {

expect_error(
rows_patch(data, tibble(a = 2:3, b = "z"), by = c("a", "b")),
class = "dplyr_rows_patch_missing"
"patch missing"
)

expect_silent(
Expand Down Expand Up @@ -73,7 +73,7 @@ test_that("rows_delete()", {

expect_error(
rows_delete(data, tibble(a = 2:4)),
class = "dplyr_rows_delete_missing"
"delete missing"
)

expect_identical(
Expand All @@ -83,7 +83,7 @@ test_that("rows_delete()", {

expect_error(
rows_delete(data, tibble(a = 2:3, b = "b"), by = c("a", "b")),
class = "dplyr_rows_delete_missing"
"delete missing"
)
})

Expand Down

0 comments on commit 2855355

Please sign in to comment.