[ic] Usertag return value

Grant emailgrant at gmail.com
Tue Feb 10 22:16:13 UTC 2009

>> > but that kills the whole page.  What is the correct way to do this
>> > so I can evaluate whether or not the tag executed properly?
>> You could use exceptions with an Interchange [try] block (see
>> etc/log_transaction for an example), but I think a simple return
>> value would suffice in this case. If you want a "0" return value when
>> one or more of the sizes fails, then use a return value variable and
>> only set it to true if all three succeed.
> Hey,
> Right, there's a bunch of ways to do this, depending on
> whether you want to know which one failed (and exit immediately),
> or you want to run all three anyway and just indicate the exit
> status more as an information than an error.
> If you want to exit immediately when one fails, use i.e.:
> do_resize(....) or return 0;

Is it a good practice to add "or return 0;" to the end of every
command in a usertag?  That way if something fails no further
processing will take place.

- Grant

> (The above assumes do_resize() indicates success with non-zero value.
> If it instead indicates failure with non-zero value, replace "or" with
> "and").
> Another approach, if you want to run all three always, and just use
> exit status as an information to see which one(s) failed:
> $ret= 0;
> do_resize1(...) or $ret+= 1;
> do_resize2(...) or $ret+= 2;
> do_resize3(...) or $ret+= 4;
> return $ret;
> So if the tag exits with 0, it worked. Otherwise, the exit
> status will be a sum of all resizes that failed. I.e. if
> exit value is 5, it means resizes 1 and 3 failed.
> Cya,
> -doc

More information about the interchange-users mailing list