Recommended scijava way to check / report / throw exception for invalid parameters?

Is there a standard / recommended scijava way to check parameter validity and report a message to the user / dev ?

e.g. maybe something like this?

#@ Dataset data;
#@ UIService ui;

if( data.numDimensions() > 5 )
{
   ui.showDialog( "This plugin requires data having fewer than five dimensions" );
}

In BoneJ we use the “validater” callback to check the input image, and cancel the plugin if it’s not appropriate. E.g.

@Parameter(validater = "validateImage")
private ImgPlus<T> inputImage;

private void validateImage() {
		// AxisUtils is our own code, not a standard part of ImageJ
        if (AxisUtils.countSpatialDimensions(inputImage) != 3) {
			cancel(NOT_3D_IMAGE);
			return;
		}
}
3 Likes