From 65ae4df2e3b529f298eb2b6402b2dfd9462311be Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 13 Oct 2016 14:17:13 +0100 Subject: [PATCH] Bug 17425: Add the Object::MethodNotCoveredByTests exception --- Koha/Exceptions/Object.pm | 6 +++++- Koha/Object.pm | 2 +- t/db_dependent/Koha/Objects.t | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Koha/Exceptions/Object.pm b/Koha/Exceptions/Object.pm index e08b5a5..2ffa1ec 100644 --- a/Koha/Exceptions/Object.pm +++ b/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; diff --git a/Koha/Object.pm b/Koha/Object.pm index d2a1d6d..fe3c40e 100644 --- a/Koha/Object.pm +++ b/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 ( $@ ) { diff --git a/t/db_dependent/Koha/Objects.t b/t/db_dependent/Koha/Objects.t index 61aaefb..41ac8cc 100644 --- a/t/db_dependent/Koha/Objects.t +++ b/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 { -- 2.8.1