Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Moose and exceptions

by stvn (Monsignor)
on Mar 19, 2008 at 19:19 UTC ( #675075=note: print w/ replies, xml ) Need Help??


in reply to Moose and exceptions

This question got answered in #moose on IRC, but just so that Perlmonks has the answer, here you go.

The conflict is in the Moose export &with and the Error export &with. There are a couple of solutions possible:

  • Since Moose uses Sub::Exporter it is possible to rename &with in the export, like so:
    package Foo::Role; use Moose::Role; package Foo; use Moose with => { -as => "moose_with" }; use Error qw(:try) moose_with("Foo::Role"); Foo->does("Foo::Role") # returns true
  • Or, use a different Exception module, Exception::Class is an excellent choice and known to work work just fine with Moose.

-stvn


Comment on Re: Moose and exceptions
Download Code
Re^2: Moose and exceptions
by glide (Pilgrim) on Mar 20, 2008 at 11:54 UTC

    It's nice to see the flexibility of the Moose. But, imho, that kind of change in the interface, will affect the maintainability of the code.

    Probably the use of the Exception::Class will be a better approach.

    many thanks
      It's nice to see the flexibility of the Moose.

      I can take no credit, we are simply riding on the shoulders of Sub::Exporter.

      But, imho, that kind of change in the interface, will affect the maintainability of the code.

      I completely agree, this is a case of "just cause you can do it, doesn't mean you should".

      -stvn

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://675075]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2014-12-27 19:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls