Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

If you, as core developer, believe that "exceptions are the way to go", why does Moose produce such horrible, unhelpful, Java-style backtraces when dieing? For example when a type constraint is violated, I get about 7 lines of output that contribute nothing to the error cause, and have to combine the first and the last line to make up something that might actually relate to the error at hand:

Q:\>perl -MMoose -e "package Moo;use Moose; has 'foo' => (is => 'ro', +isa => 'Int'); no Moose; package main; my $bar = Moo->new({foo => 'bo +om'});" Attribute (foo) does not pass the type constraint because: Validation +failed for 'Int' failed with value boom at g:/Systeme/tools/pe rl-5.10.0/perl/site/lib/Moose/Meta/ line 774 Moose::Meta::Attribute::_coerce_and_verify('Moose::Meta::Attri +bute=HASH(0x190c5f4)', 'boom', 'Moo=HASH(0x190c934)') called a t g:/Systeme/tools/perl-5.10.0/perl/site/lib/Moose/Meta/ l +ine 428 Moose::Meta::Attribute::initialize_instance_slot('Moose::Meta: +:Attribute=HASH(0x190c5f4)', 'Moose::Meta::Instance=HASH(0x187 145c)', 'Moo=HASH(0x190c934)', 'HASH(0x3ea354)') called at g:/Systeme/ +tools/perl-5.10.0/perl/site/lib/Class/MOP/ line 365 Class::MOP::Class::_construct_instance('Moose::Meta::Class=HAS +H(0x187104c)', 'HASH(0x3ea354)') called at g:/Systeme/tools/pe rl-5.10.0/perl/site/lib/Class/MOP/ line 352 Class::MOP::Class::new_object('Moose::Meta::Class=HASH(0x18710 +4c)', 'HASH(0x3ea354)') called at g:/Systeme/tools/perl-5.10.0 /perl/site/lib/Moose/Meta/ line 205 Moose::Meta::Class::new_object('Moose::Meta::Class=HASH(0x1871 +04c)', 'HASH(0x3ea354)') called at g:/Systeme/tools/perl-5.10. 0/perl/site/lib/Moose/ line 25 Moose::Object::new('Moo', 'HASH(0x12ca3ec)') called at -e line + 1

If you think something is a good engineering practice when using your tool, wouldn't it be a good idea to design your tool in a way that your tool encourages the practice instead of hindering it? Sending the programmer on a merry chase along exception paths is not friendly to the programmer.

If you use one of the standard exception mechanisms, like for example Carp, judicious use of @CARP_NOT can slim down the backtrace tree easily. Also, either passing down the (top-level) error cause to the place where the error gets detected will improve the feedback instead of requiring the programmer to intuit the error cause from the message(s) they get.

In reply to Re^4: Moose: return null object by Corion
in thread Moose: return null object by halfcountplus

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    [erix]: ( median troll aka 'the bird' )

    How do I use this? | Other CB clients
    Other Users?
    Others musing on the Monastery: (7)
    As of 2018-06-21 16:34 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (118 votes). Check out past polls.