Skip to content

Commit 10208a7

Browse files
committed
use rlang for errors
1 parent 1c6a575 commit 10208a7

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

R/accFunctions.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#' @family internal
2424
.binToDec <- function(x){
2525
if (length(x[x > 1]) > 0){
26-
stop("not a binary number")
26+
rlang::abort("not a binary number")
2727
}
2828
power <- 2 ^ (rev(seq_along(x)) - 1)
2929
return(sum(x * power))
@@ -142,11 +142,11 @@ wellsFromANSII <- function(wellSelection){
142142
} else if (length(volumes) == 8){
143143
# check for mismatch between selected tips and supplied volumes
144144
if (sum(tipMask * volumes - volumes) < 0){
145-
stop("tipMask / volumes mismatch!")
145+
rlang::abort("tipMask / volumes mismatch!")
146146
}
147147
volumes12 <- c(volumes, rep(0, 4))
148148
} else {
149-
stop("volumes vector not of length 8 (or 1)")
149+
rlang::abort("volumes vector not of length 8 (or 1)")
150150
}
151151

152152
volumes_str <- vector("character", 12L)
@@ -170,11 +170,11 @@ getGridSite <- function(RackLabel){
170170
site <- RackLabel_wt$site
171171
} else if (dim(RackLabel_wt)[1] < 1){
172172
print(gwl$worktable$worktable)
173-
stop(paste0("Racklabel: "), RackLabel,
173+
rlang::abort(paste0("Racklabel: "), RackLabel,
174174
" not defined. Define Racklabels using addToWorktable() or manually @ gwl$worktable")
175175
} else if (dim(RackLabel_wt)[1] > 1){
176176
print(gwl$worktable$worktable)
177-
stop("Duplicate RackLabels? check worktable")
177+
rlang::abort("Duplicate RackLabels? check worktable")
178178
}
179179
return(list(site = site, grid = grid))
180180
}

R/advGwlFunctions.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ moveMCA <- function(
468468
as.vector(matrix(1:384, 24, 16)[c(T, F), c(F, T)]),
469469
as.vector(matrix(1:384, 24, 16)[c(F, T), c(F, T)]))
470470
} else {
471-
stop("must target a 96 or a 384well plate!")
471+
rlang::abort("must target a 96 or a 384well plate!")
472472
}
473473
wellSelection_string <- ANSIIFromWells(wellSelection, ncol, nrow)
474474
GridSite <- getGridSite(RackLabel)
@@ -531,7 +531,7 @@ MCAvector <- function(
531531
CMadd_warning <- ""
532532

533533
if (site == 0){
534-
stop("MCAVector Sites start with 1 (from the back)!!!!")
534+
rlang::abort("MCAVector Sites start with 1 (from the back)!!!!")
535535
}
536536

537537
MCAVector_command <- str_c(

R/base.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,12 @@ addToWorktable <- function(RackLabel = "",
183183
subset(worktable, RackLabel == labware_add$RackLabel[i]))[1]
184184

185185
if (RackLabel_defined == 1){
186-
stop("RackLabel already defined")
186+
rlang::abort("RackLabel already defined")
187187
} else {
188188
gridSiteCheck <-
189189
worktable[worktable$grid == grid & worktable$site == site, ]
190190
if (dim(gridSiteCheck)[1] == 1){
191-
stop(paste0("Grid/Site allready occupied by ", gridSiteCheck$RackLabel))
191+
rlang::abort(paste0("Grid/Site allready occupied by ", gridSiteCheck$RackLabel))
192192
}
193193
worktable <- rbind(worktable, labware_add[i, ])
194194
}

R/pickoloFunctions.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ readColonies <- function(csv_path,
9191

9292
growth <- unique(growth)
9393
if (dim(growth)[1] != n_row * n_col) {
94-
stop("Data set not complete")
94+
rlang::abort("Data set not complete")
9595
}
9696

9797
output <- list(

0 commit comments

Comments
 (0)