scijava-common
scijava-common copied to clipboard
Improve error message for missing required parameters
See https://github.com/scijava/scijava-common/issues/380#issuecomment-595975277.
Maybe we can add some API (to ObjectService? somewhere else?) to keep track of human-friendly types, such as:
String friendlyType = objectService.getHumanFriendlyName(Type type); // e.g. RandomAccessibleInterval => "an image"
(falling back to "an object"),
and then something like:
"This operation requires " + name + " of type " + type + "."
... to generate an error message such as:
This operation requires an image of type RandomAccessibleInterval.
While looking into this, I was surprised to find that there is a different (slightly better?) message already, located in CheckInputsPreprocessor:
https://github.com/scijava/scijava-common/blob/3d64e2a2ea9f6eab5d75c7e778dc3da75bd03f90/src/main/java/org/scijava/module/process/CheckInputsPreprocessor.java#L56-L58
... but it never/rarely gets executed because AbstractInputHarvester is taking it:
https://github.com/scijava/scijava-common/blob/3d64e2a2ea9f6eab5d75c7e778dc3da75bd03f90/src/main/java/org/scijava/widget/AbstractInputHarvester.java#L121-L124