Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re^3: unless/if

by Moron (Curate)
on Oct 12, 2005 at 08:17 UTC ( #499412=note: print w/replies, xml ) Need Help??

in reply to Re^2: unless/if
in thread unless/if

die produces debugging information suitable for programmers but annoying for users. Programmers want to know about line numbers. Users want information that will indicate a functional solution and don't like to see even partial stack traces - it makes them believe, quite reasonably, that the program wasn't actually ready for release and that someone didn't do their job and maybe should even be fired - in fact it's hard to argue against that.


Free your mind

Replies are listed 'Best First'.
Re^4: unless/if
by sgifford (Prior) on Oct 12, 2005 at 15:49 UTC
    If you stick a "\n" on the end of the string you pass to die, you won't get a line number.

    Apart from better readability and being a standard idiom, the nice thing about using die is you can catch it in a eval, making it possible to deal with exceptional conditions at a higher level.

      Adding the "\n" to get rid of traceback info is the least part of the problem and does not address the real situation that professional programmers will frequently encounter, requiring more to be done on encountering a fatal error that needs to be brought to user's rather than just an IT person's attention and which may need support some time after the fact.
      <condition> or ProjectName::Die( $gddref, "message content" ); # in package ProjectName sub Die my $gddref = shift; # ref. to global data dictionary my $content = shift; my $UICB = $gddref -> { CB }{ UIOUT }; my $logref = $gddref -> { FH }{ LOGOUT }; &$UICB( "FATAL ERROR: $content" ); # which may or may not end up # using die depending # on the user interface print $logref ( ProjFormatTime( localtime() ) . ": $content\n"; exit 1; # having met such particular messaging requirements # die with or without "\n" is no longer an obvious idea. }
      which is more to type than:<code> Die( "


      Free your mind

Re^4: unless/if
by sth (Priest) on Oct 12, 2005 at 16:58 UTC

    ...and to add to sgifford's reply, adding a "\n" to the end of the a warn statement will eliminate the lines numbers being printed, just like die.

Re^4: unless/if
by blazar (Canon) on Oct 13, 2005 at 08:34 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://499412]
[Corion]: hippo: Yes, but I'm not sure that it's even worth the effort of implementing it at all...
[Corion]: You'll only ever need that option if you have a long-running query whose results are not cached by your DB already, and in those cases I presume that the programmer will want to maintain the temporary tables themselves - I wouldn't know when to drop ...
[Corion]: ... the temporary tables, and also don't have a good idea on how to create unique table names for them
[hippo]: OIC. In that case leave it out but invite feature requests and see if any of the users suggest it. :-)
[Corion]: Talking about this makes me realize that it's likely only a half useful idea. But it still would be convenient to have as an option...
[Corion]: hippo: Hmmm - yeah, I could document it and wait for code implementing that option to show up ;-D

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (11)
As of 2017-02-23 15:36 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (347 votes). Check out past polls.