Gossamer Forum
Home : Products : Gossamer Links : Discussions :

"die" in plug-in code

Quote Reply
"die" in plug-in code
Doesn't work.....

That was what the bug I was chasing was:

Code:
open (OUTFILE,">>$out_file") or die "could not open $filename ($cfg->{image_path}): $!";
Does _NOT_ stop execution, probably because it's already wrapped in an eval.

What was happening is my program was hitting a fatal condition, and just returning, with half the values set. My poor curly little tail is all chewed up from being chased for so long!

The only way I see around that is to create my own error handler.... unless you have a way built in.

It has to generate a 'fatal' stop, and return a message as to why, so it would have to be a multiple-statement process which doesn't lend itself to the right side of a logical 'or' or 'and'.



PUGDOG®
PUGDOG® Enterprises, Inc.
FAQ: http://pugdog.com/FAQ


Quote Reply
Re: "die" in plug-in code In reply to
Would this work, reliably:

open (OUTFILE,">>$out_file") or
( (GT::Plugins->action ( STOP ) ) && (return ( {%$input, error => "could not open $out_file : $!"} )));


and give the expected results?


Is there a better way? Putting the results into a subroutine means trying to bounce out 2 levels, and starts to make the code uglier rather than prettier.

PUGDOG®
PUGDOG® Enterprises, Inc.
FAQ: http://pugdog.com/FAQ


Quote Reply
Re: "die" in plug-in code In reply to
Hi,

I made this as a design decision so that a plugin error would not crash your site. Right now, the error will show up in your error logs as something like:

GT::Plugins (123): Plugin: error running pre hook: $hook. Reason: $@

I've updated it now so that if you have debug turned on, it will fatal, otherwise it will just print the error message to the error log.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: "die" in plug-in code In reply to
Cool....

Couldn't have asked for more! Preplanning, and options!



PUGDOG®
PUGDOG® Enterprises, Inc.
FAQ: http://pugdog.com/FAQ