From 3c615d58cf78329b9522ad9de523806cb82ccf5a Mon Sep 17 00:00:00 2001 From: schuemie Date: Thu, 4 Jul 2024 08:36:18 +0200 Subject: [PATCH] More informative error messages when analysis specifications are inconsistent. --- NEWS.md | 5 +++++ R/Analyses.R | 2 +- R/RunAnalyses.R | 8 ++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/NEWS.md b/NEWS.md index 50617c6..81e86a5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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()`. diff --git a/R/Analyses.R b/R/Analyses.R index d822217..68e616e 100644 --- a/R/Analyses.R +++ b/R/Analyses.R @@ -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() diff --git a/R/RunAnalyses.R b/R/RunAnalyses.R index de2cae7..99b3bb8 100644 --- a/R/RunAnalyses.R +++ b/R/RunAnalyses.R @@ -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 { @@ -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 { @@ -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 { @@ -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 {