Catch specific exceptions

Everything OAD-related that won't fit in the other categories: share general aspects of macro programming and discuss the OAD environment
Post Reply
user-6033
Posts: 89
Joined: Thu Jan 01, 1970 1:00 am

Catch specific exceptions

Post by user-6033 »

Hi

I have tried this:

try:
SomeImage = Zen.Processing.Segmentation.Theshold(....)
except OperationCanceledException:
sys.exit(...)

I get the error message that the exception is not globaly defined when I click on cancel. I assumed the excpetion is related to cancel button. How to catch these specific thrown exceptions that are mentioned in the OAD documention?

Kind regards
Fredrik Olsson
user-4
Posts: 397
Joined: Thu Jan 01, 1970 1:00 am

Post by user-4 »

Fredrik Olsson,

your approach to catch the OperationCanceledException is very interesting but, as you have discovered, is not supported by the macro object model.

In many cases the variable is not set when the action is canceled, so you could try something like

if SomeImage is None:
user-6033
Posts: 89
Joined: Thu Jan 01, 1970 1:00 am

Post by user-6033 »

Thanks!
I will do that.

Kind regards
Fredrik Olsson
Post Reply