Skip to content

Commit

Permalink
Refined exception messages
Browse files Browse the repository at this point in the history
  • Loading branch information
vruusmann committed Apr 20, 2024
1 parent 79b94d1 commit f90041c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public Object getPreprocessor(){
Object object = getOptionalObject("preprocessor");

if(object != null){
throw new AttributeException("Attribute \'" + ClassDictUtil.formatMember(this, "preprocessor") + "\' has an unsupported value (" + ClassDictUtil.formatClass(object) + ")");
throw new AttributeException("Attribute \'" + ClassDictUtil.formatMember(this, "preprocessor") + "\' must be set to the missing (None) value");
}

return object;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.jpmml.converter.regression.RegressionModelUtil;
import org.jpmml.python.AttributeException;
import org.jpmml.python.ClassDictUtil;
import org.jpmml.python.PythonFormatterUtil;
import sklearn.Estimator;
import sklearn.VersionUtil;
import sklearn.linear_model.LinearClassifier;
Expand All @@ -67,7 +68,7 @@ public Model encodeModel(Schema schema){
} else

{
throw new AttributeException("Attribute \'" + ClassDictUtil.formatMember(this, "multi_class") + "\' must be explicitly set to the \'" + LogisticRegression.MULTICLASS_OVR + "\' or \'" + LogisticRegression.MULTICLASS_MULTINOMIAL + "\' value");
throw new AttributeException("Attribute \'" + ClassDictUtil.formatMember(this, "multi_class") + "\' must be set to one of " + PythonFormatterUtil.formatValue(LogisticRegression.MULTICLASS_OVR) + " or " + PythonFormatterUtil.formatValue(LogisticRegression.MULTICLASS_MULTINOMIAL) + " values");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.jpmml.python.CastFunction;
import org.jpmml.python.ClassDictUtil;
import org.jpmml.python.HasArray;
import org.jpmml.python.PythonFormatterUtil;
import org.jpmml.python.TupleUtil;
import org.jpmml.sklearn.SkLearnEncoder;
import sklearn.Initializer;
Expand Down Expand Up @@ -90,7 +91,7 @@ public Boolean getDefault(){
Object object = getOptionalObject("default");

if(!Objects.equals(Boolean.FALSE, object)){
throw new AttributeException("Attribute \'" + ClassDictUtil.formatMember(this, "default") + "\' must be set to the 'False' value");
throw new AttributeException("Attribute \'" + ClassDictUtil.formatMember(this, "default") + "\' must be set to the " + PythonFormatterUtil.formatValue(Boolean.FALSE) + " value");
}

return (Boolean)object;
Expand Down

0 comments on commit f90041c

Please sign in to comment.