Bug 18137: Add useful Koha::Exceptions
[koha.git] / Koha / Exceptions.pm
1 package Koha::Exceptions;
2
3 use Modern::Perl;
4
5 use Exception::Class (
6
7     # General exceptions
8     'Koha::Exceptions::Exception' => {
9         description => 'Something went wrong!',
10     },
11     'Koha::Exceptions::BadParameter' => {
12         isa => 'Koha::Exceptions::Exception',
13         description => 'Bad parameter was given',
14         fields => ["parameter"],
15     },
16     'Koha::Exceptions::DuplicateObject' => {
17         isa => 'Koha::Exceptions::Exception',
18         description => 'Same object already exists',
19     },
20     'Koha::Exceptions::ObjectNotFound' => {
21         isa => 'Koha::Exceptions::Exception',
22         description => 'The required object doesn\'t exist',
23     },
24     'Koha::Exceptions::CannotDeleteDefault' => {
25         isa => 'Koha::Exceptions::Exception',
26         description => 'The default value cannot be deleted'
27     },
28     'Koha::Exceptions::MissingParameter' => {
29         isa => 'Koha::Exceptions::Exception',
30         description => 'A required parameter is missing'
31     },
32     'Koha::Exceptions::WrongParameter' => {
33         isa => 'Koha::Exceptions::Exception',
34         description => 'One or more parameters are wrong',
35     },
36     'Koha::Exceptions::CannotAddLibraryLimit' => {
37         isa => 'Koha::Exceptions::Exception',
38         description => 'General problem adding a library limit'
39     },
40     'Koha::Exceptions::UnderMaintenance' => {
41         isa => 'Koha::Exceptions::Exception',
42         description => 'Koha is under maintenance.'
43     },
44     # Virtualshelves exceptions
45     'Koha::Exceptions::Virtualshelves::DuplicateObject' => {
46         isa => 'Koha::Exceptions::DuplicateObject',
47         description => "Duplicate shelf object",
48     },
49     'Koha::Exceptions::Virtualshelves::InvalidInviteKey' => {
50         isa => 'Koha::Exceptions::Exception',
51         description => 'Invalid key on accepting the share',
52     },
53     'Koha::Exceptions::Virtualshelves::InvalidKeyOnSharing' => {
54         isa => 'Koha::Exceptions::Exception',
55         description=> 'Invalid key on sharing a shelf',
56     },
57     'Koha::Exceptions::Virtualshelves::ShareHasExpired' => {
58         isa => 'Koha::Exceptions::Exception',
59         description=> 'Cannot share this shelf, the share has expired',
60     },
61     'Koha::Exceptions::Virtualshelves::UseDbAdminAccount' => {
62         isa => 'Koha::Exceptions::Exception',
63         description => "Invalid use of database administrator account",
64     }
65 );
66
67 1;