Make a block protocol fail

16 views
Skip to first unread message

Ricard Delgado Gonzalo

unread,
Feb 9, 2015, 4:10:23 AM2/9/15
to icy-so...@googlegroups.com
Hello,
I am writing some block protocol. It turns out that in some cases the execution leads nowhere because the input parameters are not valid. In this case, I'd like to make the block fail, and pass that information to the protocol. Is that possible?
Thanks

Ricard

Alexandre Dufour

unread,
Feb 9, 2015, 4:33:46 AM2/9/15
to icy-so...@googlegroups.com
Hi Ricard,

Long time no see!
What exactly do you mean by “passing the information”?

If your block parameters are invalid, you may throw any kind of runtime exception (VarException being the preferred one), and this will interrupt the protocol and display the error message of your liking.

But perhaps you meant “continuing” the protocol without throwing an exception, knowing that parameters are invalid?


--
You received this message because you are subscribed to the Google Groups "Icy imaging" group.
To unsubscribe from this group and stop receiving emails from it, send an email to icy-software...@googlegroups.com.
To post to this group, send email to icy-so...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/icy-software/707c9031-eb7e-4acc-aa9b-2332d500a3a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ricard Delgado Gonzalo

unread,
Feb 9, 2015, 5:22:54 AM2/9/15
to icy-so...@googlegroups.com
Hi Alexandre,

I'm glad to be back :)
I've noticed that sometimes the block is executed without input parameters (e.g., no input image at all). I'd like to stop the execution of the protocol right away. I believe that using VarException is the best option, right?

Ricard

Alexandre Dufour

unread,
Feb 9, 2015, 5:48:57 AM2/9/15
to icy-so...@googlegroups.com
Oh, in this particular case, it’s even simpler: wherever you access the image, make sure you use

VarSequence.getValue(true); // forbids null values

instead of

VarSequence.getValue(); // allows null values

This will automatically throw a VarException if the parameter is not set. In addition to this, you may indeed throw a VarException whenever necessary.

Alexandre

Ricard Delgado Gonzalo

unread,
Feb 9, 2015, 7:00:54 AM2/9/15
to icy-so...@googlegroups.com
Great! I'll use those methods.
Cheers,

Ricard
Reply all
Reply to author
Forward
0 new messages