Commit | Line | Data |
5f7fd749 |
1 | package SQL::Translator::Schema::Role::Error; |
2 | use Moo::Role; |
3 | |
4 | has error => (is => 'rw', default => sub { '' }); |
5 | |
6 | around error => sub { |
7 | my ($orig, $self) = (shift, shift); |
8 | |
45287c81 |
9 | # Emulate horrible Class::Base API |
10 | unless (ref ($self)) { |
11 | my $errref = do { no strict 'refs'; \${"${self}::_ERROR"} }; |
12 | return $$errref unless @_; |
13 | $$errref = $_[0]; |
14 | return undef; |
15 | } |
16 | |
5f7fd749 |
17 | return $self->$orig unless @_; |
45287c81 |
18 | $self->$orig(@_); |
5f7fd749 |
19 | return undef; |
20 | }; |
21 | |
22 | 1; |