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

(-)a/Koha/Exceptions/Plugin.pm (-1 / +41 lines)
Lines 31-37 use Exception::Class ( Link Here
31
        isa         => 'Koha::Exceptions::Plugin',
31
        isa         => 'Koha::Exceptions::Plugin',
32
        description => 'Required method is missing',
32
        description => 'Required method is missing',
33
        fields      =>  ['plugin_name','method']
33
        fields      =>  ['plugin_name','method']
34
    }
34
    },
35
    'Koha::Exceptions::Plugin::InstallDied' => {
36
        isa         => 'Koha::Exceptions::Plugin',
37
        description => 'The plugin died on install',
38
        fields      => ['plugin_class'],
39
    },
40
    'Koha::Exceptions::Plugin::UpgradeDied' => {
41
        isa         => 'Koha::Exceptions::Plugin',
42
        description => 'The plugin died on upgrade',
43
        fields      => ['plugin_class'],
44
    },
35
);
45
);
36
46
37
sub full_message {
47
sub full_message {
Lines 43-48 sub full_message { Link Here
43
        if ( $self->isa('Koha::Exceptions::Plugin::MissingMethod') ) {
53
        if ( $self->isa('Koha::Exceptions::Plugin::MissingMethod') ) {
44
            $msg = sprintf("Cannot use plugin (%s) because the it doesn't implement the '%s' method which is required.", $self->plugin_name, $self->method );
54
            $msg = sprintf("Cannot use plugin (%s) because the it doesn't implement the '%s' method which is required.", $self->plugin_name, $self->method );
45
        }
55
        }
56
        elsif ( $self->isa('Koha::Exceptions::Plugin::InstallDied') ) {
57
            $msg = sprintf("Calling 'install' died for plugin %s", $self->plugin_class);
58
        }
59
        elsif ( $self->isa('Koha::Exceptions::Plugin::UpgradeDied') ) {
60
            $msg = sprintf("Calling 'upgrade' died for plugin %s", $self->plugin_class);
61
        }
46
    }
62
    }
47
63
48
    return $msg;
64
    return $msg;
Lines 73-78 method and it doesn't. Link Here
73
89
74
=back
90
=back
75
91
92
=head2 Koha::Exceptions::Plugin::InstallDied
93
94
Exception to be used when a plugin 'install' method explodes.
95
96
=head3 Parameters
97
98
=over
99
100
=item plugin_class: the plugin class
101
102
=back
103
104
=head2 Koha::Exceptions::Plugin::UpgradeDied
105
106
Exception to be used when a plugin 'upgrade' method explodes.
107
108
=head3 Parameters
109
110
=over
111
112
=item plugin_class: the plugin class
113
114
=back
115
76
=head1 Class methods
116
=head1 Class methods
77
117
78
=head2 full_message
118
=head2 full_message
(-)a/t/Koha/Exceptions.t (-2 / +28 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 8;
20
use Test::More tests => 9;
21
use Test::MockObject;
21
use Test::MockObject;
22
use Test::Exception;
22
use Test::Exception;
23
23
Lines 309-311 subtest 'Koha::Exceptions::Patron tests' => sub { Link Here
309
        'Exception is thrown :-D';
309
        'Exception is thrown :-D';
310
    is( "$@", 'Manual message exception', 'Exception not stringified if manually passed' );
310
    is( "$@", 'Manual message exception', 'Exception not stringified if manually passed' );
311
};
311
};
312
- 
312
313
subtest 'Koha::Exceptions::Plugin tests' => sub {
314
315
    plan tests => 5;
316
317
    use_ok("Koha::Exceptions::Plugin");
318
319
    my $plugin_class = 'yahey';
320
321
    throws_ok
322
        { Koha::Exceptions::Plugin::InstallDied->throw(
323
            plugin_class => $plugin_class ); }
324
        'Koha::Exceptions::Plugin::InstallDied',
325
        'Exception is thrown :-D';
326
327
    # stringify the exception
328
    is( "$@", "Calling 'install' died for plugin $plugin_class", 'Exception stringified correctly' );
329
330
    throws_ok
331
        { Koha::Exceptions::Plugin::UpgradeDied->throw(
332
            plugin_class => $plugin_class ); }
333
        'Koha::Exceptions::Plugin::UpgradeDied',
334
        'Exception is thrown :-D';
335
336
    # stringify the exception
337
    is( "$@", "Calling 'upgrade' died for plugin $plugin_class", 'Exception stringified correctly' );
338
};

Return to bug 29121