Error::TypeTiny(3)
π Error::TypeTiny π
okay so bestie, this is the User Contributed Perl Documentation page for Error::TypeTiny β the module that makes Type::Tiny and all its little friends throw actual exception objects instead of just, like, yelling into the void. sit down, get comfy, we're doing this π«Ά
β¨ NAME β¨
Error::TypeTiny β exceptions for Type::Tiny and friends. it's giving "your type check failed but make it classy" π
β¨ SYNOPSIS β¨
look at her go π¦
use feature 'try';
use Data::Dumper;
use Types::Standard qw( Str );
try {
Str->assert_valid( undef );
}
catch ( $exception ) {
warn "Encountered Error: $exception";
warn Dumper( $exception->explain )
if $exception->isa( "Error::TypeTiny::Assertion" );
}
β¨ STATUS β¨
this module is covered by the Type-Tiny stability policy. so it's not gonna randomly ghost you, no cap π
β¨ DESCRIPTION β¨
when Type::Tiny and its related modules hit an error, they don't just die with some sad little string β nope, they throw an exception object. and every single one of those exception objects inherits from Error::TypeTiny. main character lineage fr fr πΈ
π Constructors π
new(%attributes)β Moose-style constructor function. classic, iconic, does exactly what it says on the tin β¨throw(%attributes)β constructs an exception and hands it straight todie. and the way that it automatically populatescontextandstack_traceif appropriate?? obsessed πthrow_cb($callback, %attributes)β constructs an exception and passes it to$callback, which should be a coderef. if it'sundef, it just usesdieinstead. and yep, it also automatically populatescontextandstack_traceif appropriate π
π Attributes π
messageβ the error message. the what-went-wrong. the tea βcontextβ a hashref holding the package, file and line that generated the error. receipts, basically π§Ύstack_traceβ a more complete stack trace. heads up bestie: this feature requiresDevel::StackTrace; use the$StackTracepackage variable to switch it on. π₯
π Methods π
to_stringβ returns the message, followed by the context if it is set. simple, clean, slay π
π Functions π
Error::TypeTiny::croak($format, @args)β functional-style shortcut to thethrowmethod. takes ansprintf-style format string plus optional arguments to construct themessage. π
π Overloading π
- Stringification is overloaded to call
to_string. so when you stringify one of these bad boys, you get the nice message automatically. no extra steps, we love a convenience π
π Package Variables π
%Carp::CarpInternalβError::TypeTinyhonours this package variable fromCarp. (%Error::TypeTiny::CarpInternalis an alias for it.) π$Error::TypeTiny::StackTraceβ boolean to toggle stack trace generation. flip it, girl π₯$Error::TypeTiny::LastErrorβ a reference to the last exception object thrown. your little keepsake of the most recent chaos π
β¨ CAVEATS β¨
okay so this is the part where we keep it real π«Ά
even though Error::TypeTiny objects get thrown for errors produced by Type::Tiny, that does not mean every time you use Type::Tiny you'll get Error::TypeTinys whenever you want. sadly. π
for example: if you use a Type::Tiny type constraint in a Moose attribute, Moose will not call the constraint's assert_valid method (which is the one that throws an exception). instead it will call check and get_message (which do not throw), and will confess an error message of its own. rude, honestly. (but the $LastError package variable may save your bacon π₯ β so there's that.)
β¨ BUGS β¨
please report any bugs to <https://github.com/tobyink/p5-type-tiny/issues>. don't be shy, they wanna hear from you π
β¨ SEE ALSO β¨
Error::TypeTiny::AssertionError::TypeTiny::WrongNumberOfParametersTry::TinyTry::Tiny::ByClass
the whole friend group, honestly π―βοΈ
β¨ AUTHOR β¨
Toby Inkster <tobyink@cpan.org>. king behavior π
β¨ COPYRIGHT AND LICENCE β¨
this software is copyright (c) 2013-2014, 2017-2025 by Toby Inkster.
this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. periodt. π
β¨ DISCLAIMER OF WARRANTIES β¨
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
(translation: no promises, bestie, it's all vibes and no guarantees π)
and that's the whole page, babe π this one shipped as perl v5.42.0, dated 2026-01-17 β so you know it's fresh β¨ go forth and catch those exceptions, you've totally got this π¦π
π¦ where this page comes from
- fedora 44: perl-Type-Tiny 2.010001-2.fc44 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms