View | Details | Raw Unified | Return to bug 27806
Collapse All | Expand All

(-)a/Koha/Exceptions/Object.pm (+4 lines)
Lines 40-45 use Exception::Class ( Link Here
40
    'Koha::Exceptions::Object::PropertyNotFound' => {
40
    'Koha::Exceptions::Object::PropertyNotFound' => {
41
        isa => 'Koha::Exceptions::Object',
41
        isa => 'Koha::Exceptions::Object',
42
        description => "Invalid property",
42
        description => "Invalid property",
43
        fields      => ['property', 'clause'],
43
    },
44
    },
44
    'Koha::Exceptions::Object::ReadOnlyProperty' => {
45
    'Koha::Exceptions::Object::ReadOnlyProperty' => {
45
        isa => 'Koha::Exceptions::Object',
46
        isa => 'Koha::Exceptions::Object',
Lines 84-89 sub full_message { Link Here
84
        elsif ( $self->isa('Koha::Exceptions::Object::NotInstantiated') ) {
85
        elsif ( $self->isa('Koha::Exceptions::Object::NotInstantiated') ) {
85
            $msg = sprintf("Tried to access the '%s' method, but %s is not instantiated", $self->method, $self->class );
86
            $msg = sprintf("Tried to access the '%s' method, but %s is not instantiated", $self->method, $self->class );
86
        }
87
        }
88
        elsif ( $self->isa('Koha::Exceptions::Object::PropertyNotFound') ) {
89
            $msg = sprintf("Invalid property '%s' in '%s' clause", $self->property, $self->clause );
90
        }
87
    }
91
    }
88
92
89
    return $msg;
93
    return $msg;
(-)a/Koha/Objects.pm (-3 / +27 lines)
Lines 22-27 use Modern::Perl; Link Here
22
use Carp;
22
use Carp;
23
use List::MoreUtils qw( none );
23
use List::MoreUtils qw( none );
24
use Class::Inspector;
24
use Class::Inspector;
25
use Try::Tiny;
25
26
26
use Koha::Database;
27
use Koha::Database;
27
use Koha::Exceptions::Object;
28
use Koha::Exceptions::Object;
Lines 409-417 Returns an arrayref of the objects in this set. Link Here
409
=cut
410
=cut
410
411
411
sub as_list {
412
sub as_list {
412
    my ( $self ) = @_;
413
    my ($self) = @_;
413
414
414
    my @dbic_rows = $self->_resultset()->all();
415
    my @dbic_rows = try {
416
        $self->_resultset()->all();
417
    }
418
    catch {
419
        if ( ref($_) eq 'DBIx::Class::Exception' ) {
420
            #warn $_->{msg};
421
            if ( $_->{msg} =~
422
                /Unknown column '(?<column>.*?)' in 'where clause'/ )
423
            {
424
                Koha::Exceptions::Object::PropertyNotFound->throw(
425
                    property => $+{column},
426
                    clause   => 'where'
427
                );
428
            }
429
            elsif ( $_->{msg} =~
430
                /Unknown column '(?<column>.*?)' in 'order clause'/ )
431
            {
432
                Koha::Exceptions::Object::PropertyNotFound->throw(
433
                    property => $+{column},
434
                    clause   => 'order'
435
                );
436
            }
437
        }
438
        $_->rethrow();
439
    };
415
440
416
    my @objects = $self->_wrap(@dbic_rows);
441
    my @objects = $self->_wrap(@dbic_rows);
417
442
418
- 

Return to bug 27806