Moose::Exception(3)

πŸ’– Moose::Exception πŸ’–

okay bestie, gather round, because this one is Moose::Exception β€” the superclass for Moose internal exceptions. yes, the whole class. she's the mother of all Moose exceptions and she is serving.


✨ VERSION ✨

version 2.4000 β€” that's the one, no cap πŸ’…


🌸 DESCRIPTION 🌸

so like, this class is where all the attributes live that every single Moose internal exception class has in common. it's the shared closet, the group chat, the communal snack drawer. every Moose exception subclass gets these vibes by default 🫢


πŸ’€ WARNING WARNING WARNING πŸ’€

okay this is the important part and i need you to lock in:

if you're out here writing your own exception classes, you should instead prefer the Throwable role or the Throwable::Error superclass. this thing right here is effectively a cut-down internal fork of Throwable::Error, and it is not designed for use in user code. not for you. not for your app. it's backstage-only, iykyk πŸ™ˆ

of course if you're writing metaclass traits, then it would make total sense to subclass the relevant Moose exceptions β€” but only then. literally only then. that's the vibe check and this class fails it for everyone else 😭


πŸŽ€ METHODS πŸŽ€

$exception->message

this attribute contains the exception message. that's it, that's the whole thing β€” the words that tell you what went wrong.

every subclass of Moose::Exception is expected to override the _build_message method in order to construct this value. so if you're subclassing, that's your homework, bestie πŸ“

$exception->trace

this attribute contains the stack trace for the given exception. it returns a Devel::StackTrace object. so when things go sideways you can see exactly where the chaos started πŸ”₯

$exception->as_string

this method returns a stringified form of the exception, including a stack trace. iconic, honestly.

by default, this method skips Moose-internal stack frames until it sees a caller outside of the Moose core β€” so you get the tea without all the Moose-internal noise ✨

but if the MOOSE_FULL_EXCEPTION environment variable is true, those frames are included. full chaos mode, everything on the table, no filtering πŸ‘‘


πŸ‘‘ SEE ALSO πŸ‘‘

  • Moose::Manual::Exceptions

🌈 AUTHORS 🌈

the legends themselves, the ones who made this happen:

  • Stevan Little <stevan@cpan.org>
  • Dave Rolsky <autarch@urth.org>
  • Jesse Luehrs <doy@cpan.org>
  • Shawn M Moore <sartak@cpan.org>
  • Χ™Χ•Χ‘Χœ Χ§Χ•Χ’'מן (Yuval Kogman) <nothingmuch@woobling.org>
  • Karen Etheridge <ether@cpan.org>
  • Florian Ragwitz <rafl@debian.org>
  • Hans Dieter Pearcey <hdp@cpan.org>
  • Chris Prather <chris@prather.org>
  • Matt S Trout <mstrout@cpan.org>

periodt. πŸ’–


this software is copyright (c) 2006 by Infinity Interactive, Inc.

this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. slay, open source, we love to see it πŸ¦‹


and that's a wrap, bestie 🫢 this was Moose::Exception(3) from the User Contributed Perl Documentation, perl v5.42.0, dated 2025-07-25. go forth, subclass responsibly, and remember: not for user code unless you're doing metaclass traits πŸ’…βœ¨

πŸ“¦ where this page comes from