Data::...::Error(3pm)
β¨ NAME β¨
Data::Util::Error β bestie, this is the module that deals with class-specific error handlers in Data::Util π
Like, it's the lil' helper that lets each class have its own opinion about what a failure looks like. Very main character of it, honestly.
π¦ SYNOPSIS π¦
okay okay here's the vibe, look:
package Foo;
use Data::Util::Error sub{ Foo::InvalidArgument->throw_error(@_) };
use Data::Util qw(:validate);
sub f{
my $x_ref = array_ref shift; # Foo::InvalidArgument is thrown if invalid
# ...
}
so like. you tell Data::Util::Error what your class throws β your handler, your rules β and then all the validation stuff from Data::Util just... uses it? iconic. if array_ref gets handed something that is not an array ref, boom, Foo::InvalidArgument gets thrown, no cap π
π Functions π
here come the actual functions, bestie, don't skip:
Data::Util::Error->fail_handler()β call it with no args and it hands you back the current fail handler. no drama, just vibes.Data::Util::Error->fail_handler($handler)β call it with a$handlerand you're setting the fail handler for the class. this is the one youruse Data::Util::Error sub{ ... }is secretly sliding into, iykyk πData::Util::Error::croak(@args)β the function that goes and does the croaking for you, passing along@args. it's giving "I'll handle the screaming, you just relax" π
π SEE ALSO π
Data::Util.β go read that one next, fr fr π«Ά
okay that's the whole page, you made it, I'm so proud of you π₯Ήβ¨
this was pulled from perl v5.42.3, dated 2026-08-19 β shoutout perl, the blueprint, the blueprint, the blueprint ππ§ββοΈ like, mwah. go write some error handlers bestie ππ
π¦ where this page comes from
- ubuntu stonking: libdata-util-perl 0.67-1build7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms