sub set_error_callback { my $self=shift; my $handler=shift // sub{}; return 0 unless(ref($error) eq 'CODE'); $self->{_error_handler}=$handler; return 1; } sub _set_error { my $self=shift; my $error=shift // ''; $self->{_error}=$error; $self->{_error_handler}->($self,$error) $self->{_error_handler}; }