When using Fetch to download a url from Teamcity I get a Fetch failed! error. But the download of the file actually works.
They have recently changed permissions of our
It seems that the problem is a warning (message) being printed to STDERR
. Apparently you are not getting a die
or the program would exit. You can control the process of printing the message by setting the $SIG{__WARN__}
hook, best localized in a block.
my $where;
FETCH: {
local $SIG{__WARN__} = sub {
print "WARN: @_"; # or whatever appropriate
};
$where = $ff->fetch ( to => "$DOWNLOAD_LOCATION" );
};
or
my $where = do {
local $SIG{__WARN__} = sub { print "WARN: @_" };
$ff->fetch;
};
The signal's disposition – to print to STDERR
– is restored outside of the block, which is what local
provides. See this in perlsub, in particular text right after "Synopsis". You can also do that manually by saying $SIG{__WARN__} = 'DEFAULT';
once you are done.
See warn
No message is printed if there is a
$SIG{__WARN__}
handler installed. It is the handler's responsibility to deal with the message as it sees fit (like, for instance, converting it into a die).
Also see %SIG
entry in perlvar
The routine indicated by
$SIG{__WARN__}
is called when a warning message is about to be printed. The warning message is passed as the first argument. The presence of a__WARN__
hook causes the ordinary printing of warnings to STDERR to be suppressed.
While deciding what to call an "error" and what a "warning" may be a bit arbitrary, it appears clear that your program only emits a message to STDERR
and continues. Then the above should suffice.
If you were being hit by a die
then you could wrap the code in eval.
As the documentation explains, just set
$File::Fetch::WARN = 0;
to suppress warnings.