Skip to content

Commit

Permalink
fix #396 - better catch unexpected validation error
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Nov 25, 2024
1 parent 4c89e4b commit ebf7113
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion R/geoflow_validator.R
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,7 @@ geoflow_validator <- R6Class("geoflow_validator",

#'@description Validates a source table using syntactic and content validation rules
#'@param raw indicates whether to return a \code{list} of \code{geoflow_validator_cell} objects or a \code{data.frame}
#'@param debug debug validation
#'@return a \code{list} of \code{geoflow_validator_cell} objects, or \code{data.frame}
validate_content = function(raw = FALSE){
content_validation_report <- NULL
Expand All @@ -906,7 +907,12 @@ geoflow_validator <- R6Class("geoflow_validator",
if(is.R6Class(col_validator_class)){
out_col <- col_validator_class$new(i, which(colnames(src_obj)==colname), src_obj[,colname])
if(!raw){
out_col <- out_col$validate()

out_col <- try(out_col$validate(), silent = T)
if(is(out_col,"try-error")){
stop(sprintf("Unexpected validation error for row %s column %s ('%s'), value '%s':\n%s",
i, which(colnames(src_obj)==colname), colname, src_obj[,colname], out_col[1]))
}
out_col <- cbind(col = rep(colname,nrow(out_col)), out_col)
}
}
Expand Down
2 changes: 2 additions & 0 deletions man/geoflow_validator.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ebf7113

Please sign in to comment.