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

Unhandled errors must error properly (#797)

parent 08bdc86e
......@@ -32,6 +32,10 @@ Booster <- R6Class(
params <- append(params, list(...))
params_str <- lgb.params2str(params)
handle <- 0.0
# Attempts to create a handle for the dataset
try({
# Check if training dataset is not null
if (!is.null(train_set)) {
......@@ -92,9 +96,16 @@ Booster <- R6Class(
stop("lgb.Booster: Need at least either training dataset, model file, or model_str to create booster instance")
}
})
# Check whether the handle was created properly if it was not stopped earlier by a stop call
if (lgb.is.null.handle(handle)) {
stop("lgb.Booster: cannot create Booster handle")
} else {
# Create class
class(handle) <- "lgb.Booster.handle"
private$handle <- handle
......@@ -102,6 +113,7 @@ Booster <- R6Class(
private$num_class <- lgb.call("LGBM_BoosterGetNumClasses_R",
ret = private$num_class,
private$handle)
}
},
......
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