| 1 | package Data::CouchDB::Exceptions; | ||
| 2 | |||
| 3 | use 5.006; | ||
| 4 | use strict; | ||
| 5 | use warnings; | ||
| 6 | |||
| 7 | our $VERSION = '0.14'; | ||
| 8 | |||
| 9 | =head1 NAME | ||
| 10 | |||
| 11 | Data::CouchDB - CouchDB document management | ||
| 12 | |||
| 13 | =cut | ||
| 14 | |||
| 15 | use Exception::Class ( | ||
| 16 | |||
| 17 | 'Data::CouchDB::Exception' => { | ||
| 18 | fields => ['uri', 'error'], | ||
| 19 | isa => 'Exception::Class::Base' | ||
| 20 | }, | ||
| 21 | |||
| 22 | 'Data::CouchDB::ConnectionFailed' => { | ||
| 23 | isa => 'Data::CouchDB::Exception', | ||
| 24 | description => 'Connection to couch db failed', | ||
| 25 | }, | ||
| 26 | |||
| 27 | 'Data::CouchDB::DBNotFound' => { | ||
| 28 | isa => 'Data::CouchDB::Exception', | ||
| 29 | description => 'The DB you are looking for does not exist', | ||
| 30 | fields => ['uri', 'error', 'db'], | ||
| 31 | }, | ||
| 32 | |||
| 33 | 'Data::CouchDB::RetrieveFailed' => { | ||
| 34 | isa => 'Data::CouchDB::Exception', | ||
| 35 | description => 'Document is not found in couch', | ||
| 36 | fields => ['db', 'uri', 'error', 'document'], | ||
| 37 | }, | ||
| 38 | |||
| 39 | 'Data::CouchDB::RevisionNotMatched' => { | ||
| 40 | isa => 'Data::CouchDB::Exception', | ||
| 41 | description => 'Revision of document provided not match the one in couch', | ||
| 42 | fields => ['db', 'uri', 'error', 'document'], | ||
| 43 | }, | ||
| 44 | |||
| 45 | 'Data::CouchDB::UpdateFailed' => { | ||
| 46 | isa => 'Data::CouchDB::Exception', | ||
| 47 | description => 'Revision of document provided not match the one in couch', | ||
| 48 | fields => ['db', 'uri', 'error', 'document'], | ||
| 49 | }, | ||
| 50 | |||
| 51 | 'Data::CouchDB::QueryFailed' => { | ||
| 52 | isa => 'Data::CouchDB::Exception', | ||
| 53 | description => 'Revision of document provided not match the one in couch', | ||
| 54 | fields => ['db', 'uri', 'error', 'view'], | ||
| 55 | }, | ||
| 56 | ); | ||
| 57 | |||
| 58 | sub full_message { my $self = shift; return 'Connection to db ' . $self->db . '@' . $self->uri . ' failed with error ' . $self->error; } | ||
| 59 | |||
| 60 | 1; |