in reply to Re: Perl Style: About error messges opening files
in thread Perl Style: About error messges opening files

If it's going to show up in an error log, I just make sure it's a unique string that I can grep for easily

Ehm. I always thought the filename and line number included in the error message (if you don't let it end in \n) made that unnecessary. They're not scary, not even to beginners. Beginners learn to ignore these things the minute they start using a unixish system, developers learn to look at the line mentioned. That way, you increase the chance of getting a patch with the bug report if it happens to be a bug.

Besides, going to a certain line number is much faster and easier than grepping or searching.

Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

  • Comment on Re: Re: Perl Style: About error messges opening files

Replies are listed 'Best First'.
Re: Re: Re: Perl Style: About error messges opening files
by Anonymous Monk on Apr 28, 2004 at 18:59 UTC

    using a random uniq message allows you to easily change the message to something better later on.

    s/mumble foo:/missing input file:/ s/bonk:/unknown request:/ s/what the frell:/data base seems broken:/
Re: Perl Style: About error messges opening files
by jonadab (Parson) on Apr 30, 2004 at 20:12 UTC
    going to a certain line number is much faster and easier than grepping or searching

    Not in my experience. A line number is harder to hold in your head, so you probably have to copy-and-paste it from wherever (browser, email, log, ...) into the jump-to-line feature of your text editor. As opposed to just hitting ctrl-S and typing the first N characters of a phrase. By the time you get to the second word, you're there usually there.

    I always thought the filename and line number included in the error message

    If you're getting the error message from a logfile or at the command prompt maybe. If an end user sees the message and tries to remember it to tell you, the chances of a full filepath coming through accurately, much less a line number, are vanishingly close to zero. A phrase like "Twinkies and Spandex" is significantly more likely to get to you intact.


    ;$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$;[-1]->();print

      A line number is harder to hold in your head

      When you have 852442 line files, maybe, but I'm perfectly capable of remembering 3 digits for a short time. I'm sure that if you try, you can also do that. Sometimes, but not often, there are 4 digits. Still not at all hard.

      If an end user sees the message and tries to remember it to tell you

      Error messages are sent to me by email. The one time per week that someone actually calls, they're always reading it off the screen. Perhaps you code for the internetless?

      A phrase like "Twinkies and Spandex" is significantly more likely to get to you intact.

      bar.txt: No such file or directory at foo.pl line 15
      versus
      Twinkies and Spandex (No such file or directory)
      Something tells me you're wasting my time.

      Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

        I'm perfectly capable of remembering 3 digits for a short time.

        So would I be, if I didn't get interrupted three times on my way from the circ desk to my desk (twenty feet) to fix the problem :-)

        Error messages are sent to me by email. The one time per week that someone actually calls, they're always reading it off the screen. Perhaps you code for the internetless?

        Close. Think in terms of people who print email and have to disconnect from the internet to use the phone. Also, I said "End Users", so think in terms of people who don't know how to copy and paste. (Really. I've been teaching introductory computer classes twice a month at the library since 2000 and have by doing so significantly increased the number of people in town who copy and paste. Yes, Galion is a fairly technophobic community. People have access to the internet, but they're not comfortable with it.)

        Nearly half of the bug reports I get are on sticky notes. Most of the rest are delivered verbally, either in person (this is WAY more common than you would suspect) or on the phone -- and, as noted, almost all of the internet connections around here are dialup, and most people don't have a second line for voice, so they have to disconnect to use the phone. Couple that with an end-user mentality that requires them to "x out of" (i.e., close) the web browser in order to disconnect, and you have a recipe for not being able to remember an error message to give it to me. When I first started this job, vanishingly close to 100% of the bug reports I got were totally useless, along the lines of "it didn't work". Worse, when I started asking them to write down the error message next time and bring it to me, I discovered that they had no idea what to write down and so usually wrote down a non-unique part of the message. (No amount of cajoling can get most end users to write down an _entire_ error message if it has any length to it at all.) An error message like "Grouchy Pickles" will actually _get_ to me, because it sticks in the user's head; then I grep for it, and I know which line the error occurred on, which is more than I was usually able to discover from error reports before I adopted this technique.

        If you're writing stuff that gets used mostly by powerusers then you probably won't need this technique.


        ;$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$;[-1]->();print