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 $handler and you're setting the fail handler for the class. this is the one your use 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