Flabbergasted

merijnb on 2003-09-04T14:19:30

Sometimes I can still be amazed by the code I am presented with. Yesterday I was helping out somebody to debug his script. This used some helper application, also written in Perl. The helper app returned with an error. Which is fine.

The error message was "unknown error". Which could be fine, but definitely isn't helpful. Looking in the helper application at the actual code to see where it decides that it has an error that it doesn't know about, which is an odd concept if you think about it, I came across the following construction:

if ($errorstring =~ /something/) {
    return "Something error"
} elsif ... {
    ...
} else {
   return "unknown error"
}

WTF? So the programmer of this code had the $errorstring, but chooses not to pass it back. Furffu.

Glad it is Perl though, where I can copy the code, change it and find out what actually is the problem.