Wrap some over-log has statements
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Role / Error.pm
CommitLineData
45595850 1package SQL::Translator::Role::Error;
5f7fd749 2use Moo::Role;
68d75205 3use Sub::Quote qw(quote_sub);
5f7fd749 4
d24c55fe 5has _ERROR => (
6 is => 'rw',
7 accessor => 'error',
8 init_arg => undef,
68d75205 9 default => quote_sub(q{ '' }),
d24c55fe 10);
5f7fd749 11
12around error => sub {
13 my ($orig, $self) = (shift, shift);
14
45287c81 15 # Emulate horrible Class::Base API
d24c55fe 16 unless (ref($self)) {
17 my $errref = do { no strict 'refs'; \${"${self}::ERROR"} };
45287c81 18 return $$errref unless @_;
19 $$errref = $_[0];
20 return undef;
21 }
22
5f7fd749 23 return $self->$orig unless @_;
45287c81 24 $self->$orig(@_);
5f7fd749 25 return undef;
26};
27
281;