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

(-)a/C4/Members.pm (-3 / +3 lines)
Lines 400-408 sub AddMember { Link Here
400
400
401
    my $category = Koha::Patron::Categories->find( $data{categorycode} );
401
    my $category = Koha::Patron::Categories->find( $data{categorycode} );
402
    unless ($category) {
402
    unless ($category) {
403
        Koha::Exceptions::BadParameter->throw(
403
        Koha::Exceptions::Object::FKConstraint->throw(
404
            error => 'Invalid parameter passed',
404
            broken_fk => 'categorycode',
405
            parameter => 'categorycode'
405
            value     => $data{categorycode},
406
        );
406
        );
407
    }
407
    }
408
408
(-)a/Koha/Exceptions.pm (-4 / +1 lines)
Lines 1-13 Link Here
1
package Koha::Exceptions;
1
package Koha::Exceptions;
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
use Koha::Exceptions::Exception;
4
5
5
use Exception::Class (
6
use Exception::Class (
6
7
7
    # General exceptions
8
    'Koha::Exceptions::Exception' => {
9
        description => 'Something went wrong!',
10
    },
11
    'Koha::Exceptions::BadParameter' => {
8
    'Koha::Exceptions::BadParameter' => {
12
        isa => 'Koha::Exceptions::Exception',
9
        isa => 'Koha::Exceptions::Exception',
13
        description => 'A bad parameter was given',
10
        description => 'A bad parameter was given',
(-)a/Koha/Exceptions/Object.pm (-3 / +2 lines)
Lines 3-11 package Koha::Exceptions::Object; Link Here
3
use Modern::Perl;
3
use Modern::Perl;
4
4
5
use Exception::Class (
5
use Exception::Class (
6
7
    'Koha::Exceptions::Object' => {
6
    'Koha::Exceptions::Object' => {
8
        description => 'Something went wrong!',
7
        isa         => 'Koha::Exceptions::Exception',
9
    },
8
    },
10
    'Koha::Exceptions::Object::DuplicateID' => {
9
    'Koha::Exceptions::Object::DuplicateID' => {
11
        isa         => 'Koha::Exceptions::Object',
10
        isa         => 'Koha::Exceptions::Object',
Lines 15-21 use Exception::Class ( Link Here
15
    'Koha::Exceptions::Object::FKConstraint' => {
14
    'Koha::Exceptions::Object::FKConstraint' => {
16
        isa         => 'Koha::Exceptions::Object',
15
        isa         => 'Koha::Exceptions::Object',
17
        description => "Foreign key constraint broken",
16
        description => "Foreign key constraint broken",
18
        fields      =>  ['broken_fk']
17
        fields      =>  ['broken_fk', 'value'],
19
    },
18
    },
20
    'Koha::Exceptions::Object::MethodNotFound' => {
19
    'Koha::Exceptions::Object::MethodNotFound' => {
21
        isa => 'Koha::Exceptions::Object',
20
        isa => 'Koha::Exceptions::Object',
(-)a/Koha/Object.pm (-2 lines)
Lines 131-137 sub store { Link Here
131
                # FIXME: MySQL error, if we support more DB engines we should implement this for each
131
                # FIXME: MySQL error, if we support more DB engines we should implement this for each
132
                if ( $_->{msg} =~ /FOREIGN KEY \(`(?<column>.*?)`\)/ ) {
132
                if ( $_->{msg} =~ /FOREIGN KEY \(`(?<column>.*?)`\)/ ) {
133
                    Koha::Exceptions::Object::FKConstraint->throw(
133
                    Koha::Exceptions::Object::FKConstraint->throw(
134
                        error     => 'Broken FK constraint',
135
                        broken_fk => $+{column}
134
                        broken_fk => $+{column}
136
                    );
135
                    );
137
                }
136
                }
138
- 

Return to bug 20590