Skip to content

Commit

Permalink
Refined exception messages
Browse files Browse the repository at this point in the history
  • Loading branch information
vruusmann committed Mar 22, 2019
1 parent 22ab727 commit 2931027
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/jpmml/h2o/DrfMojoModelConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public MiningModel encodeModel(Schema schema){
int ntreesPerGroup = getNTreesPerGroup(model);

if(model._mojo_version < 1.2d){
throw new IllegalArgumentException();
throw new IllegalArgumentException("Version " + model._mojo_version + " is not supported");
}

Label label = schema.getLabel();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jpmml/h2o/GbmMojoModelConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public MiningModel encodeModel(Schema schema){
int ntreesPerGroup = getNTreesPerGroup(model);

if(model._mojo_version < 1.2d){
throw new IllegalArgumentException();
throw new IllegalArgumentException("Version " + model._mojo_version + " is not supported");
}

Label label = schema.getLabel();
Expand Down Expand Up @@ -119,7 +119,7 @@ public MiningModel encodeModel(Schema schema){
} else

{
throw new IllegalArgumentException();
throw new IllegalArgumentException("Distribution family " + model._family + " is not supported");
}
}
}
8 changes: 6 additions & 2 deletions src/main/java/org/jpmml/h2o/GlmMojoModelBaseConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,12 @@ public Schema toMojoModelSchema(Schema schema){
int[] catModes = getCatModes(model);
double[] numMeans = getNumMeans(model);

if(cats != catModes.length || nums != numMeans.length){
throw new IllegalArgumentException();
if(catModes.length != cats){
throw new IllegalArgumentException("Expected " + cats + " mode values, got " + catModes.length + " mode values");
} // End if

if(numMeans.length != nums){
throw new IllegalArgumentException("Expected " + nums + " mean values, got " + numMeans.length + " mean values");
}

for(int i = 0; i < cats; i++){
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jpmml/h2o/H2OEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void setLabel(DataField dataField){
setLabel(new CategoricalLabel(dataField));
break;
default:
throw new IllegalArgumentException();
throw new IllegalArgumentException("Expected categorical or continuous operational type, got " + opType.value() + " operational type");
}
}

Expand All @@ -83,7 +83,7 @@ public void addFeature(DataField dataField){
addFeature(new CategoricalFeature(this, dataField));
break;
default:
throw new IllegalArgumentException();
throw new IllegalArgumentException("Expected categorical or continuous operational type, got " + opType.value() + " operational type");
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/jpmml/h2o/SharedTreeMojoModelConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public Node encodeNode(Predicate predicate, AtomicInteger idSequence, byte[] com

int colId = byteBuffer.get2();
if(colId == 65535){
throw new IllegalArgumentException();
throw new IllegalArgumentException("Feature index 65535 is not supported");
}

int naSplitDir = byteBuffer.get1U();
Expand Down Expand Up @@ -119,7 +119,7 @@ public Node encodeNode(Predicate predicate, AtomicInteger idSequence, byte[] com
} else

{
throw new IllegalArgumentException();
throw new IllegalArgumentException("Node type " + equal + " is not supported");
}

FieldName name = categoricalFeature.getName();
Expand Down Expand Up @@ -207,7 +207,7 @@ public Node encodeNode(Predicate predicate, AtomicInteger idSequence, byte[] com
rightByteBuffer.skip(4);
break;
default:
throw new IllegalArgumentException();
throw new IllegalArgumentException("Node type " + lmask + " is not supported");
}

if((lmask2 & 16) != 0){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,12 @@ public Model encodeModel(Schema schema){
MojoModel mojoModel = getMojoModel(baseModel);
double[] mapping = getMapping(baseModel);

// XXX
if(!(mojoModel instanceof SharedTreeMojoModel) || (mapping != null)){
throw new IllegalArgumentException();
if(!(mojoModel instanceof SharedTreeMojoModel)){
throw new IllegalArgumentException("Stacking of models other than decision tree models is not supported");
} // End if

if(mapping != null){
throw new IllegalArgumentException("Feature re-indexing is not supported");
}

Converter<?> converter = converterFactory.newConverter(mojoModel);
Expand Down

0 comments on commit 2931027

Please sign in to comment.