1SQL::Translator::Role::UEsrerrorC(o3n)tributed Perl DocuSmQeLn:t:aTtriaonnslator::Role::Error(3)
2
3
4
6 SQL::Translator::Role::Error - Error setter/getter for objects and
7 classes
8
10 In the class consuming the role:
11
12 package Foo;
13 use Moo;
14 with qw(SQL::Translator::Role::Error);
15
16 sub foo {
17 ...
18 return $self->error("Something failed")
19 unless $some_condition;
20 ...
21 }
22
23 In code using the class:
24
25 Foo->foo or die Foo->error;
26 # or
27 $foo->foo or die $foo->error;
28
30 This Moo::Role provides a method for getting and setting error on a
31 class or object.
32
34 $object_or_class->error([$message])
35 If called with an argument, sets the error message and returns undef,
36 otherwise returns the message.
37
38 As an implementation detail, for compatibility with Class::Base, the
39 message is stored in "$object->{_ERROR}" or $Class::ERROR, depending on
40 whether the invocant is an object.
41
43 • "Error Handling" in Class::Base
44
45
46
47perl v5.34.1 2022-05-10 SQL::Translator::Role::Error(3)