Skip to content

Commit f68d311

Browse files
Treiblesschorlegselzer
authored andcommitted
Improve error messages
1 parent f4af886 commit f68d311

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

‎src/main/java/org/scijava/ops/matcher/OpCandidate.java‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,10 @@ public String toString() {
202202
}
203203

204204
public StructInstance<?> createOp() {
205-
// Nobody seems to set it to MATCH yet
206-
// if (!getStatusCode().equals(StatusCode.MATCH)) {
207-
// // TODO: Logging
208-
// return null;
209-
// }
210-
205+
if (!getStatusCode().equals(StatusCode.MATCH)) {
206+
throw new IllegalArgumentException(
207+
"Status of candidate to create op " + "from indicates a problem: " + getStatus());
208+
}
211209
final Class<?> opClass = opInfo().opClass();
212210
final Object object;
213211
try {
@@ -218,9 +216,8 @@ public StructInstance<?> createOp() {
218216
} catch (final InstantiationException | IllegalAccessException e) {
219217
// TODO: Think about whether exception handling here should be
220218
// different.
221-
// TODO: Logging
222-
// log.error("Cannot instantiate op: " + opClass.getName(), e);
223-
return null;
219+
throw new IllegalStateException("Unable to instantiate op: '" + opClass.getName()
220+
+ "' Each op must have a no-args constructor.", e);
224221
}
225222
return struct().createInstance(object);
226223
}

0 commit comments

Comments
 (0)