[ic] Usertag return value
docelic at spinlocksolutions.com
Wed Feb 11 13:10:10 UTC 2009
On Tue, 10 Feb 2009 20:33:58 -0800
Grant <emailgrant at gmail.com> wrote:
> >> > 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;
> I'm getting strange results from this now. My usertag is set up like
> write-file1 or return 0;
> write-file2 or return 0;
> write-file3 or return 0;
> The usertags exits and returns 0, the first 2 write-file commands
> execute, and none of the chmod-file commands execute. If I remove the
> "or return 0;" portions, everything executes perfectly. Does that
> make sense to anyone?
Check what return value is returned from the write-file commands...
If they return 0 or undef, then your 'return 0' part will kick in
and eject even though things were alright.
Also, for file writing and chmodding you really want to be doing
proper checking, i.e. logging or printing the value of $! when the
If you don't know where to begin or what return values come out of
your write functions, I'd go this way:
$Tag->log("wf1: return=$ret error=$!");
$Tag->log("cf1: return=$ret error=$!");
and so on for all three, and watch your catalog logfile for results...
Also, you might be able to get rid of chmod if you set a correct umask
before creating the files.
More information about the interchange-users