in reply to <rant>CPAN modules failing to check for write errors</rant>

I think you have the right of it, but there is no central authority that can force coders to do anything. That's the downside to the whole community coding thing.

I think a lot of authors ignore print failures because they program on Unix, and on Unix if you have a valid file handle you can write to it. But checking your opens is pretty poor form, I'll agree.

OTOH, I find it pretty annoying when a module throws a die. It means I have to wrap it in an eval rather than just check the return code.

If you choose to write an article, why not submit it directly to perl.com or even post it here? I hear a few CPAN authors are members of PerlMonks

The CPAN authors I've talked with have been fairly sympathetic to adding additional error checking. I suspect it's a bit of the omniscent author problem - the author knows hir code so well that error messages aren't really needed. It's actually quite hard to write good error messages for people who don't know what your code does.

Perhaps it is time to start a new perl meme for CPAN authors :)

____________________
Jeremy
I didn't believe in evil until I dated it.

  • Comment on Re: <rant>CPAN modules failing to check for write errors</rant>

Replies are listed 'Best First'.
Re: Re: <rant>CPAN modules failing to check for write errors</rant>
by Anonymous Monk on May 29, 2004 at 12:45 UTC
    Thanks for the reply.

    I appreciate throwing exceptions can be a pain in the **** - Java seems to have taken this to the extreme and it's hard to say if that's good or bad.

    Actually I don't mind if a method/function returns true/false as long as I can easily find out what the error was and where it occurred - I think exceptions are the way to go when building larger applications, but can be overkill for small scripts. BUT I do need to know if an error occurred :)

    The only reason why I'm loathed to write an article directly to perl.com is because I'm not a known name in the community, but yes I might knock something up and post it here for review. Anything to get authors just thinking about things anyway!

      I appreciate throwing exceptions can be a pain in the **** - Java seems to have taken this to the extreme

      As a sysadmin (I seem to be saying that a lot thesedays), I've seen uncaught exceptions on some genuinely insignificant errors. Plus, since they are written for programmers, the error messages are mostly useless for sysadmins. If error messages aren't going to be useful for users or sysadmins, I question their usefulness in production code.

      I agree with the 'know if error occurred', but I'd argue that showing it to the user should be the last ditch desperation response, not the default fallback. I found this with smalltalk, which would throw me a popup window for any uncaught exception - as if anyone is going to use a system like that!

      Please do write your article up. The highest quality articles I've seen on Perlmonks have been by authors who have been annoyed beyond endurance by a 'feature' of perl, or a community shortfall. Well thought out critiscism of perl is a staple here.

      ____________________
      Jeremy
      I didn't believe in evil until I dated it.

        I agree with the 'know if error occurred', but I'd argue that showing it to the user should be the last ditch desperation response, not the default fallback.
        Not being able to print to an open filehandle seems serious enough to me to warrant an exception (though I must confess that my modules don't check for it)