Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Error reporting in Perl

by Jambo Hamon (Novice)
on Jul 13, 2017 at 00:41 UTC ( #1194969=perlmeditation: print w/replies, xml ) Need Help??

Use of /c modifier is meaningless without /g at (eval 14) line 1, <__A +NONIO__> line 4.

Would it not be nice to see the offending string in an error code, taint approved? And if it's not a string... Then it's not Perl.

I slay me,
Jambo

Replies are listed 'Best First'.
Re: Error reporting in Perl
by Corion (Pope) on Jul 13, 2017 at 08:48 UTC

    To find your error locations easier, you can use Sub::Name to give them a name.

    Note that the "original string" may not be available anymore once Perl comes to the conclusion that your code tries to do something nonsensical.

    Maybe you can show us a more concrete example that reproduces your situation and show us what you would like to see instead.

      Agree.   Is the essential complaint that things are being output (by Perl, itself) to STDERR, and you wish to capture these outputs within your program?

      I would candidly suggest that this sort of issue represents a bit of a conundrum for a language (or package) designer, in a language-environment such as this which really doesn’t have a well-defined notion of “message severity,” nor any well-defined mechanism for handling different severity-levels.   (In other environments with which I am familiar, there are levels such as “Fatal, Error, Warning, Informational.”)   The present message would qualify as an “Informational” message ... which Perl (AFAIK) does not really have the means to support.

      In this case, “although it worked,” I want to tell you something.   In the Perl environment, the presence of a reported error-message generally implies that it didn’t work, and I would daresay that there is today a vast amount of Perl5 legacy code which acts upon precisely that very assumption.   Therefore, “the resulting conundrum, I would think, is non-trivial.”

      (And, I think, well worth exploring.   We really do need a much-better way to handle this, within the Perl5 environment, please without breaking anything (good luck with that).   Did I overlook something?   If so, I really(!) want to know!)

        Of course, Perl has three well-defined levels of messages, "fatal" as represented by die, "warning" as represented by warn and "log" as represented by print.

        As you certainly are aware, Perl also has separate mechanisms of handling these messages and whether Perl issues them at all.

        So, please reminiscence back on your claimed vast experience and reevaluate whether you still think the "resulting conundrum ... is non-trivial".

        Past experience has shown that even if you say "really(!)" want to know that you won't act upon that knowledge though.

        I would daresay

        You're choosing the wrong voice in your head to listen to. Try the other one.

        > Did I overlook something?
        Knowing anything on the topic, actually answering OPs question?
Re: Error reporting in Perl
by shmem (Chancellor) on Jul 13, 2017 at 22:45 UTC
    Would it not be nice to see the offending string in an error code, taint approved?

    Agreed. Although I hate python for the significant whitespace at line beginning, I hate it far more for uninformative stacktraces, which do show me the formal parameters per default, but not the values they carry. This is similar.

    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
Re: Error reporting in Perl
by RonW (Vicar) on Jul 17, 2017 at 21:57 UTC

    Maybe turn on regex debugging during development:use re qw(Debug COMPILE);

    re is a core module, so should not need to be installed.)

Re: Error reporting in Perl
by jdporter (Canon) on Jul 18, 2017 at 17:09 UTC
    Would it not be nice to see the offending string

    What do you mean by "the offending string"? Do you mean the line of code? Because that error message says there's a problem with the code, not with whatever string (data) was being operated upon by the regex.

    in an error code

    What do you mean by "an error code"? Do you mean "the error message"? i.e. the line which is printed by the interpreter.

    I reckon we are the only monastery ever to have a dungeon stuffed with 16,000 zombies.
Re: Error reporting in Perl
by Anonymous Monk on Jul 13, 2017 at 07:59 UTC

    Would it not be nice to see the offending string in an error code, taint approved?

    No it would be clutter

Re: Error reporting in Perl
by Anonymous Monk on Jul 13, 2017 at 15:45 UTC
    The offending string might be very long. But maybe someone has a tool that saves eval-ed strings for debugging purposes?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://1194969]
Approved by Athanasius
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2017-10-23 06:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (277 votes). Check out past polls.

    Notices?