scijava / scijava-common

A plugin framework and application container with built-in extensibility mechanism :electric_plug:
BSD 2-Clause "Simplified" License
91 stars 52 forks source link

Improve error message for missing required parameters #412

Open imagejan opened 3 years ago

imagejan commented 3 years ago

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 commented 3 years ago

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