@@ -, +, @@ --- Koha/Exceptions/Object.pm | 6 +++++- Koha/Object.pm | 2 +- t/db_dependent/Koha/Objects.t | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) --- a/Koha/Exceptions/Object.pm +++ a/Koha/Exceptions/Object.pm @@ -14,7 +14,11 @@ use Exception::Class ( 'Koha::Exceptions::Object::PropertyNotFound' => { isa => 'Koha::Exceptions::Object', description => "Invalid property", - } + }, + 'Koha::Exceptions::Object::MethodNotCoveredByTests' => { + isa => 'Koha::Exceptions::Object', + description => "Method not covered by tests", + }, ); 1; --- a/Koha/Object.pm +++ a/Koha/Object.pm @@ -239,7 +239,7 @@ sub AUTOLOAD { my @known_methods = qw( is_changed id in_storage get_column ); - carp "The method $method is not covered by tests or does not exist!" and return unless grep {/^$method$/} @known_methods; + Koha::Exceptions::Object::MethodNotCoveredByTests->throw( "The method $method is not covered by tests!" ) unless grep {/^$method$/} @known_methods; my $r = eval { $self->_result->$method(@_) }; if ( $@ ) { --- a/t/db_dependent/Koha/Objects.t +++ a/t/db_dependent/Koha/Objects.t @@ -93,8 +93,8 @@ subtest 'Exceptions' => sub { try { $patron->blah('blah'); } catch { - ok( $_->isa('Koha::Exceptions::Object::MethodNotFound'), - 'Calling a non-existent method should raise a Koha::Exceptions::Object::MethodNotFound exception' ); + ok( $_->isa('Koha::Exceptions::Object::MethodNotCoveredByTests'), + 'Calling a non-covered method should raise a Koha::Exceptions::Object::MethodNotCoveredByTests exception' ); }; try { --