ext/libsvm/libsvm.c in rb-libsvm-1.3.1 vs ext/libsvm/libsvm.c in rb-libsvm-1.4.0

- old
+ new

@@ -488,17 +488,22 @@ * * This load a model from file `filename`. Format is the LIBSVM * internal file representation of the model. * * @param filename [String] name of the model file + * @raise [IOError] if the model can't be loaded, + * e.g. because the model path doesn't point to a model * @return [Libsvm::Model] the model */ static VALUE cModel_class_load(VALUE cls, VALUE filename) { struct svm_model *model; char *path; path = StringValueCStr(filename); model = svm_load_model(path); + if(model == NULL) { + rb_raise(rb_eIOError, "unable to load model from file: \"%s\"", path); + } return Data_Wrap_Struct(cModel, 0, model_free, model); } /* call-seq: * Model.cross_validation(problem, parameter, num_fold)