Commit a2ae8384 authored by Laurae's avatar Laurae Committed by Guolin Ke
Browse files

More elegant, more obvious error for the enduser (#229)

parent 54a2356c
......@@ -80,12 +80,12 @@ Dataset <- R6Class(
if (!is.null(private$categorical_feature)) {
if (typeof(private$categorical_feature) == "character") {
cate_indices <- as.list(match(private$categorical_feature, private$colnames) - 1)
if (length(cate_indices) != length(private$categorical_feature)) {
stop("lgb.self.get.handle: cannot find feature name ", sQuote(private$categorical_feature[!private$categorical_feature %in% private$colnames]))
if (sum(is.na(cate_indices)) > 0) {
stop("lgb.self.get.handle: supplied an unknown feature in categorical_feature: ", sQuote(private$categorical_feature[is.na(cate_indices)]))
}
} else {
if (max(private$categorical_feature) > length(private$colnames)) {
stop("lgb.self.get.handle: supplied a too large value in categorical_feature")
stop("lgb.self.get.handle: supplied a too large value in categorical_feature: ", max(private$categorical_feature), " but only ", length(private$colnames), " features")
}
cate_indices <- as.list(private$categorical_feature - 1)
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment