SQL::Tr...::Error(3)

okay so bestie, welcome to SQL::Tr...::Error(3) β€” it's part of the User Contributed Perl Documentation crowd, and it's here to teach you the error setter/getter vibe for objects and classes. πŸ’–


🌸 NAME 🌸

SQL::Translator::Role::Error β€” the error setter/getter for objects and classes. no cap, that's literally the whole job. ✨


✨ SYNOPSIS ✨

In the class that's consuming the role, it looks like this:

package Foo;
use Moo;
with qw(SQL::Translator::Role::Error);

sub foo {
    ...
    return $self->error("Something failed")
        unless $some_condition;
    ...
}

And in code that's using the class, you can do either of these:

Foo->foo or die Foo->error;
# or
$foo->foo or die $foo->error;

πŸ’– DESCRIPTION πŸ’–

This Moo::Role provides a method for getting and setting error on a class or object. That's the whole main character energy of this page. πŸ’…


πŸŽ€ METHODS πŸŽ€

πŸ’… $object_or_class->error([$message]) πŸ’…

If you call it with an argument, it sets the error message and returns undef. If you call it without an argument, it returns the message. Slay. 🫢

As an implementation detail β€” and yes, for compatibility with Class::Base β€” the message is stored in $object->{_ERROR} or $Class::ERROR, depending on whether the invocant is an object. iykyk. 🧚


πŸ¦‹ SEE ALSO πŸ¦‹

  • β€œError Handling” in Class::Base β€” the related read, bestie. πŸŽ€

this page is from perl v5.42.0, dated 2024-12-12. mwah, go handle those errors bestie πŸ’œβœ¨

πŸ“¦ where this page comes from