[ic] Usertag return value

Gert van der Spoel gert at 3edge.com
Wed Feb 11 21:04:15 UTC 2009


> -----Original Message-----
> From: interchange-users-bounces at icdevgroup.org [mailto:interchange-
> users-bounces at icdevgroup.org] On Behalf Of Grant
> Sent: Wednesday, February 11, 2009 10:58 PM
> To: interchange-users at icdevgroup.org
> Subject: Re: [ic] Usertag return value
> 
> >> >> > 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
> >> this:
> >>
> >> do-stuff;
> >> write-file1 or return 0;
> >> chmod-file1;
> >> do-stuff;
> >> write-file2 or return 0;
> >> chmod-file2;
> >> do-stuff;
> >> write-file3 or return 0;
> >> chmod-file3;
> >>
> >> 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
> > error happens.
> >
> > If you don't know where to begin or what return values come out of
> > your write functions, I'd go this way:
> >
> > $ret= write-file1;
> > $Tag->log("wf1: return=$ret error=$!");
> >
> > $ret= chmod-file1;
> > $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.
> >
> > Cya,
> > -doc
> 
> I'm still not sure why "or return 0;" causes the usertag to fail so I
> changed my file writing and chmodding lines like this:
> 
> $return= $image->Write(filename=>'/file/location/'.$name.'_image.jpg')
> or return 0;
> $Tag->log("1: return=$return error=$!");
> $return= chmod(0644,"/file/location/".$name."_image.jpg") or return 0;
> $Tag->log("2: return=$return error=$!");
> 
> and the usertag fails and there is nothing in the catalog error.log.
> Can you tell me what I'm doing wrong?

* Have you tried to change 'or' for ||
* Have you tried to put:
  $return= $image->Write(filename=>'/file/location/'.$name.'_image.jpg') or
return "wet noodle";
 
  and see what it returns?

> 
> - Grant
> 
> _______________________________________________
> interchange-users mailing list
> interchange-users at icdevgroup.org
> http://www.icdevgroup.org/mailman/listinfo/interchange-users




More information about the interchange-users mailing list