Skip to content

Commit

Permalink
More informative error messages when analysis specifications are inco…
Browse files Browse the repository at this point in the history
…nsistent.
  • Loading branch information
schuemie committed Jul 4, 2024
1 parent aa7ad27 commit 3c615d5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
SelfControlledCaseSeries 5.2.3
==============================

Changes

1. More informative error messages when analysis specifications are inconsistent.


Bugfixes

1. Fixed 'ORDER BY is ignored in subqueries without LIMIT' warning when calling `createSccsIntervalData()`.
Expand Down
2 changes: 1 addition & 1 deletion R/Analyses.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ createSccsAnalysis <- function(analysisId = 1,
checkmate::assertCharacter(description, len = 1, add = errorMessages)
checkmate::assertClass(getDbSccsDataArgs, "args", add = errorMessages)
checkmate::assertClass(createStudyPopulationArgs, "args", add = errorMessages)
checkmate::assertClass(createIntervalDataArgs, "args", null.ok = TRUE, add = errorMessages)
checkmate::assertClass(createIntervalDataArgs, "args", add = errorMessages)
checkmate::assertClass(fitSccsModelArgs, "args", add = errorMessages)
checkmate::reportAssertions(collection = errorMessages)
analysis <- list()
Expand Down
8 changes: 4 additions & 4 deletions R/RunAnalyses.R
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ runSccsAnalyses <- function(connectionDetails,
for (includeEraId in settings$includeEraIds) {
if (is.character(includeEraId)) {
if (is.null(refRow[[includeEraId]])) {
stop(paste("Variable", includeEraId, " not found in exposures-outcome set"))
stop(paste0("The 'includeEraIds' argument was set to '", includeEraId, "' when calling createEraCovariateSettings(), but this exposure label is not found in exposures-outcome sets"))
}
includeEraIds <- c(includeEraIds, refRow[[includeEraId]])
} else {
Expand All @@ -348,7 +348,7 @@ runSccsAnalyses <- function(connectionDetails,
for (excludeEraId in settings$excludeEraIds) {
if (is.character(excludeEraId)) {
if (is.null(refRow[[excludeEraId]])) {
stop(paste("Variable", excludeEraId, " not found in exposure-outcome set"))
stop(paste0("The 'excludeEraIds' argument was set to '", excludeEraId, "' when calling createEraCovariateSettings(), but this exposure label is not found in exposures-outcome sets"))
}
excludeEraIds <- c(excludeEraIds, refRow[[excludeEraId]])
} else {
Expand Down Expand Up @@ -513,7 +513,7 @@ createReferenceTable <- function(sccsAnalysisList,
for (exposureId in sccsAnalysis$getDbSccsDataArgs$exposureIds) {
if (is.character(exposureId)) {
if (!exposureId %in% uniqueExposureIdRefs) {
stop(paste("Variable", exposureId, " not found in exposures-outcome sets"))
stop(paste0("The 'exposureIds' argument was set to '", exposureId, "' when calling createGetDbSccsDataArgs(), but this exposure label is not found in exposures-outcome sets"))
}
exposureIds <- c(exposureIds, referenceTable$exposureId[i])
} else {
Expand All @@ -528,7 +528,7 @@ createReferenceTable <- function(sccsAnalysisList,
for (customCovariateId in sccsAnalysis$getDbSccsDataArgs$customCovariateIds) {
if (is.character(customCovariateId)) {
if (!customCovariateId %in% uniqueExposureIdRefs) {
stop(paste("Variable", customCovariateId, " not found in exposures-outcome sets"))
stop(paste0("The 'customCovariateIds' argument was set to '", customCovariateId, "' when calling createGetDbSccsDataArgs(), but this exposure label is not found in exposures-outcome sets"))
}
customCovariateIds <- c(customCovariateIds, referenceTable[i, customCovariateId])
} else {
Expand Down

0 comments on commit 3c615d5

Please sign in to comment.