Re: Why does Net::SFTP trigger my die handler when no errors?



xhoster@xxxxxxxxx wrote:

> I think it would be nice, at least for debugging purposes, if you had your
> sub print out the error message it was called with. Then you would know
> what it was.

Do you mean $! ? I wasn't sure $! would be reliable here. I actually
included $! as I was trying to figure out what was going on, and I got
a bunch of (seemingly) meaningless messages.

> However, from perldoc perlvar:
> <snip perldoc>
> So it would be my guess that Net::SFTP is dying from inside an eval, as
> part of its normal course of business, and you are intercepting those dies.

I'm glad you were able to translate that perldoc statement (which I
struggle to understand, with little success) into something that makes
sense! Thanks!
>
> But this lead me to ask a broader question. What are you trying to do, and
> why are you using a SIG die handler, rather than eval{}, to do whatever it
> is you are tyring to do?
>
The die handler is designed to catch my own die() calls. I die within
my script under various dire circumstances, but I want to do some
housecleaning before I really leave (dispatching final logging methods,
closing databases cleanly, etc), so I use the handler. Maybe that's not
the best way to do it...

I didn't anticipate catching any die()s from Net::SFTP because the docs
for the module claim it die()s only in under fairly restrictive (and
unlikely) conditions. Your speculation about the module die()'ng inside
evals sounds plausable, and will make me re-think my exit strategy for
exception handling.

Thanks, Xho (and thanks, Sinan, for your amazing efforts to help also,
which were apparently thwarted by what seems to be a bug in Net::SSH on
Windows - but I'm a UN*X weenie).

--
http://DavidFilmer.com

.



Relevant Pages

  • Re: eval{}
    ... die on errors and just keep passing them up the line: ... As long as you keep propagating $@ in your die calls, ... method for propagating $@ out of deeply nested evals. ...
    (perl.beginners)
  • Re: Problems connecting to internet via GPRS
    ... The error message is basically saying that it can't find System.SR.dll so there's no error message. ... da die optionale Ressource der Assembly, ... If the application forces the connection itself (for example via web ... Es kann keine Fehlermeldung angezeigt werden, ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Embedded Functions in MATLAB with MPC555
    ... the Model Explorer and specify everything about the signal type on the input ... this would either work or give you a different error message. ... % Diese Variablen hälten Eigenschaften die Funktionen ... if (isempty(byte_identifier)) ...
    (comp.soft-sys.matlab)
  • Re: The non-terminating script, revisited
    ... >> to put evals around every single call? ... It's an extra level of ... With RaiseError set, whenever there is a database error, the program ... But then you catch that die with an eval. ...
    (comp.lang.perl.misc)
  • Re: Detecting line terminators in a CSV file
    ... precedence || operator means it won't die even if you wanted it to. ... I'll check out that precedence thing ... shouldn't use evalto print an error message from a built-in function. ... openfails it returns undef and puts the error message in $!. ...
    (perl.beginners)