Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: Your use of assertions in Perl ?

by AZed (Monk)
on Sep 19, 2008 at 20:34 UTC ( [id://712621]=note: print w/replies, xml ) Need Help??


in reply to Re: Your use of assertions in Perl ?
in thread Your use of assertions in Perl ?

Never assert about items that you can't control, such as content from the www or a user - you'll just have to find some way of coping with errors in that.

I'd modify that to, "Never assert about items that neither you or your intended users can control." An assertion is a perfectly valid way to inform a user, "stop mangling your input data", though you are right of course in that it is nothing more than a source of frustration if the point of the code is for users to run it on someone else's arbitrary and potentially mangled input data.

As a corollary, however, I'd add that it's nice if your error message tells the user as much as possible about what was wrong and how to fix it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://712621]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-25 02:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found