I am getting this error
Can't call method "otherwise" without a package or object reference at ...
Before that it was
Can't call method "with" without a package or object reference at ...
So something is funky...
I have several try catch blocks in the same sub though they are mutually exclusive mostly. The others work. I recently decided I needed to add the one that is having the issue. (stupid command I am calling inexplicably fails 1 in 10,000 times) And this new one just won't work...
Here is some code...
if ( $pbOnDStarMachine == 1 ) {
my ($sComm) = "sudo dchown foo \'$this->{sFullPath}\'";
try {
libs::exec("$sComm");
} catch err with {
my ($ex) = @_;
dPrt("warn","$ex");
} otherwise {
my ($ex) = @_;
dPrt("warn","OTHERWISE:$ex");
};
return "";
}
That is the offending code.
The Exec proc is here
sub exec {
my ($comm) = @_;
if ( dbg::debugOn() ) {
dPrt("dbg","Debug, Would execute:\n$comm");
} else {
dPrt("libs_verbose","Executing:$comm");
system("$comm");
if ($? == -1) {
throw err("system command returned -1: $comm\nReason $!");
}
elsif ($? & 127) {
my ($sSig) = $? & 127;
throw err("Command died with signal $sSig :$comm");
}
else {
my ($nExitVal) = $? >> 8;
if ( $nExitVal != 0 ) {
throw err("Command exited with value $nExitVal :$comm");
}
}
}
When I first ran into the error about "with" I did some research and found that you can get that error if an exception other than the one you named gets thrown. And they suggested the addition of the otherwise clause to catch those "other" exceptions. So I dropped one in to try and basically catch all errors and convert to a warning...
But now the error is about the otherwise clause.
AS far as my research is convinced it can't be about the error type that is getting thrown, so it must be something else, perhaps the otherwise isn't related...
Anyone have any insight?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.