I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2009-08-27 17:49:11-07 by guaguanco in response to 9208
Re: Moose can't seem to coexist with Error.pm
I've confirmed this with the latest versions of Moose and Error:
--------------------------------------------------------------------- #!/usr/bin/perl -w # test-Error1 package Test; use strict; use warnings; use Moose; use Error qw(:try); try { throw_something(); } catch Error::Simple with { my $e = shift; print "caught $e\n"; } otherwise { print "Huh?\n"; }; sub throw_something { throw Error::Simple("Hi!"); } --------------------------------------------------------------------- yields: thiazole:Moose> test-Error1 Subroutine Test::with redefined at ./test-Error1 line 9 Prototype mismatch: sub Test::with: none vs (&;$) at ./test-Error1 line 9 caught Hi! at ./test-Error1 line 28. thiazole:Moose>
Here a workaround (a hack, since it slightly changes the semantics of the Error module, but it works):
--------------------------------------------------------------------------------------- # MooseError.pm BEGIN { use Error qw(:try); my ($pack) = __PACKAGE__; my $oldsym = $pack . '::with'; my $newsym = $pack . '::with_handler'; eval qq { *$newsym = *$oldsym; undef *$oldsym; }; }; 1; --------------------------------------------------------------------- #!/usr/bin/perl -w #test-Error2 package Test; use strict; use warnings; use MooseError; use Moose; try { throw_something(); } catch Error::Simple with_handler { my $e = shift; print "caught $e\n"; } otherwise { print "Huh?\n"; }; sub throw_something { throw Error::Simple("Hi!"); } --------------------------------------------------------------------- thiazole:Moose> test-Error2 caught Hi! at ./test-Error2 line 28. thiazole:Moose>
Direct Responses: 11374 | Write a response