scijava-common icon indicating copy to clipboard operation
scijava-common copied to clipboard

Improve error message for missing required parameters

Open imagejan opened this issue 4 years ago • 1 comments

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.

imagejan avatar Dec 03 '20 15:12 imagejan

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

imagejan avatar Dec 18 '20 20:12 imagejan