Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Designing Defaults for Devel::file

by bsb (Priest)
on Nov 04, 2007 at 08:12 UTC ( #648849=perlquestion: print w/replies, xml ) Need Help??

bsb has asked for the wisdom of the Perl Monks concerning the following question:

I released an alpha version of Devel::file with the intention of seeking monk preferences for the defaults. The defaults are particularly important for this module because changing them is awkward.

There's detailed documentation on the link above but the basic idea of the module is to install signal handlers that print the source code around lines giving rise to exceptions or warnings. It can be used in the command-line with -d:file although I'd like it to be safe to leave in your PERL5OPT while developing.

I asked about die/warn signal handler best practice questions already, interacting with other handlers is still a tricky business. The alpha version tries to play well with others but I'm swinging towards refusing to install if there's already another custom handler. Thoughts?

Other questions that I'm pondering are:

Should warnings be intercepted?
Should user exceptions such as croak be intercepted?
What about stack dumps? (Note that the __DIE__ handler is called just before the program ending, so shouldn't interfere with exception handling)
How many lines of context should be shown?
Should the source be appended to all errors, or inserted after each?
I received a suggestion to only show context for the first syntax error as it's often the source of later problems, agree?
Currently, I use the source available from the debugger when -d is used and fallback to using IO::All otherwise. Is it worth trying to support the two, even though there will inevitably be differences?

Other suggestions and tips welcome.

Notes on the name

-d:file was a difficult choice, the other contenters included:
-d:brief -d:flower -d:mote -d:spair -d:vic +e -d:ceased -d:form -d:notation -d:spise -d:vil -d:code -d:fuse -d:nouement -d:spot -d:voi +d -d:cry -d:grade -d:parts -d:tail -d:vot +e -d:duce -d:light -d:press -d:ter -d:fault -d:lineate -d:range -d:test -d:feat -d:mean -d:ride -d:velope -d:fect -d:mented -d:sist -d:viant


Replies are listed 'Best First'.
Re: Designing Defaults for Devel::file
by moritz (Cardinal) on Nov 04, 2007 at 09:45 UTC
    As for the name I'd suggest Devel::ErrorContext or Devel::CarpContext or something of the like.
Re: Designing Defaults for Devel::file
by bibliophile (Prior) on Nov 05, 2007 at 14:47 UTC
    Heh... -d:fault appeals to me - a play on words that can be read a couple of ways, both of which make sense :-)

    I don't know about "refusing to install"... perhaps a sternly worded warning instead?

    As far as lines of context, I would suspect that 3-4 lines before and maybe 2 lines after...? Difficult trade-off.

    For myself, I'd like to see the source/context immediately after the error. And I agree - for syntax errors, probably just showing context for the first one is enough (at least as a default... can that be overridden by the user?)

    Anyway, my $0.02CDN

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://648849]
Approved by pKai
Front-paged by grinder
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2023-02-01 03:37 GMT
Find Nodes?
    Voting Booth?

    No recent polls found