| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package ElasticSearch::Error; | 
| 2 |  |  |  |  |  |  | $ElasticSearch::Error::VERSION = '0.68'; | 
| 3 |  |  |  |  |  |  | @ElasticSearch::Error::Internal::ISA       = __PACKAGE__; | 
| 4 |  |  |  |  |  |  | @ElasticSearch::Error::Param::ISA          = __PACKAGE__; | 
| 5 |  |  |  |  |  |  | @ElasticSearch::Error::NoServers::ISA      = __PACKAGE__; | 
| 6 |  |  |  |  |  |  | @ElasticSearch::Error::ClusterBlocked::ISA = __PACKAGE__; | 
| 7 |  |  |  |  |  |  | @ElasticSearch::Error::Request::ISA        = __PACKAGE__; | 
| 8 |  |  |  |  |  |  | @ElasticSearch::Error::Timeout::ISA        = __PACKAGE__; | 
| 9 |  |  |  |  |  |  | @ElasticSearch::Error::Connection::ISA     = __PACKAGE__; | 
| 10 |  |  |  |  |  |  | @ElasticSearch::Error::JSON::ISA           = __PACKAGE__; | 
| 11 |  |  |  |  |  |  | @ElasticSearch::Error::QueryParser::ISA    = __PACKAGE__; | 
| 12 |  |  |  |  |  |  | @ElasticSearch::Error::Conflict::ISA | 
| 13 |  |  |  |  |  |  | = ( 'ElasticSearch::Error::Request', __PACKAGE__ ); | 
| 14 |  |  |  |  |  |  | @ElasticSearch::Error::Missing::ISA | 
| 15 |  |  |  |  |  |  | = ( 'ElasticSearch::Error::Request', __PACKAGE__ ); | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | @ElasticSearch::Error::NotReady::ISA | 
| 18 |  |  |  |  |  |  | = ( 'ElasticSearch::Error::Connection', __PACKAGE__ ); | 
| 19 |  |  |  |  |  |  |  | 
| 20 | 2 |  |  | 2 |  | 10 | use strict; | 
|  | 2 |  |  |  |  | 5 |  | 
|  | 2 |  |  |  |  | 80 |  | 
| 21 | 2 |  |  | 2 |  | 11 | use warnings FATAL => 'all', NONFATAL => 'redefine'; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 103 |  | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | use overload ( | 
| 24 | 2 |  |  |  |  | 15 | '""'  => 'stringify', | 
| 25 |  |  |  |  |  |  | 'cmp' => 'compare', | 
| 26 | 2 |  |  | 2 |  | 3849 | ); | 
|  | 2 |  |  |  |  | 2555 |  | 
| 27 | 2 |  |  | 2 |  | 2620 | use Data::Dumper; | 
|  | 2 |  |  |  |  | 20584 |  | 
|  | 2 |  |  |  |  | 654 |  | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | #=================================== | 
| 30 |  |  |  |  |  |  | sub stringify { | 
| 31 |  |  |  |  |  |  | #=================================== | 
| 32 | 58 |  |  | 58 | 0 | 7329 | my $error = shift; | 
| 33 | 58 |  |  |  |  | 91 | local $Data::Dumper::Terse  = 1; | 
| 34 | 58 |  |  |  |  | 87 | local $Data::Dumper::Indent = 1; | 
| 35 |  |  |  |  |  |  |  | 
| 36 | 58 | 50 | 50 |  |  | 1010 | my $msg | 
|  |  |  | 50 |  |  |  |  | 
|  |  |  | 50 |  |  |  |  | 
| 37 |  |  |  |  |  |  | = '[ERROR] ** ' | 
| 38 |  |  |  |  |  |  | . ( ref($error) || 'ElasticSearch::Error' ) . ' at ' | 
| 39 |  |  |  |  |  |  | . $error->{-file} | 
| 40 |  |  |  |  |  |  | . ' line ' | 
| 41 |  |  |  |  |  |  | . $error->{-line} . " : \n" | 
| 42 |  |  |  |  |  |  | . ( $error->{-text} || 'Missing error message' ) . "\n" | 
| 43 |  |  |  |  |  |  | . ( | 
| 44 |  |  |  |  |  |  | $error->{-vars} | 
| 45 |  |  |  |  |  |  | ? "\nWith vars:" . Dumper( $error->{-vars} ) . "\n" | 
| 46 |  |  |  |  |  |  | : '' | 
| 47 |  |  |  |  |  |  | ) . ( $error->{'-stacktrace'} || '' ); | 
| 48 | 58 |  |  |  |  | 394 | return $msg; | 
| 49 |  |  |  |  |  |  | } | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | #=================================== | 
| 52 |  |  |  |  |  |  | sub compare { | 
| 53 |  |  |  |  |  |  | #=================================== | 
| 54 | 0 |  |  | 0 | 0 |  | my ( $error, $other, $swap ) = @_; | 
| 55 | 0 |  |  |  |  |  | $error .= ''; | 
| 56 | 0 | 0 |  |  |  |  | ( $error, $other ) = ( $other, $error ) if $swap; | 
| 57 | 0 |  |  |  |  |  | return $error cmp $other; | 
| 58 |  |  |  |  |  |  | } | 
| 59 |  |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | =head1 NAME | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | ElasticSearch::Error - Exception objects for ElasticSearch | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | ElasticSearch::Error is a base class for exceptions thrown by any ElasticSearch | 
| 67 |  |  |  |  |  |  | code. | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | There are several exception subclasses, which indicate different types of error. | 
| 70 |  |  |  |  |  |  | All of them inherit from L, and all include: | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | $error->{-text}         # error message | 
| 73 |  |  |  |  |  |  | $error->{-file}         # file where error was thrown | 
| 74 |  |  |  |  |  |  | $error->{-line}         # line where error was thrown | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | They may also include: | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | $error->{-vars}         # Any relevant variables related to the error | 
| 79 |  |  |  |  |  |  | $error->{-stacktrace}   # A stacktrace, if $ElasticSearch::DEBUG == 1 | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  | Error objects can be stringified, and include all of the above information | 
| 82 |  |  |  |  |  |  | in the string output. | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | =head1 EXCEPTION CLASSES | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | =over | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | =item * ElasticSearch::Error::Param | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | An incorrect parameter was passed in | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | =item * ElasticSearch::Error::Timeout | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | The request timed out | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  | =item * ElasticSearch::Error::Connection | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | There was an error connecting to the current node. The request will be | 
| 99 |  |  |  |  |  |  | retried on another node. | 
| 100 |  |  |  |  |  |  |  | 
| 101 |  |  |  |  |  |  | =item * ElasticSearch::Error::NotReady | 
| 102 |  |  |  |  |  |  |  | 
| 103 |  |  |  |  |  |  | The current node is not yet able to serve requests. The request will be | 
| 104 |  |  |  |  |  |  | retried on another node. C inherits from | 
| 105 |  |  |  |  |  |  | C. | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | =item * ElasticSearch::Error::ClusterBlocked | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  | The cluster was unable to process the request because it is currently blocking, | 
| 110 |  |  |  |  |  |  | eg the requested index is closed. | 
| 111 |  |  |  |  |  |  |  | 
| 112 |  |  |  |  |  |  | =item * ElasticSearch::Error::Request | 
| 113 |  |  |  |  |  |  |  | 
| 114 |  |  |  |  |  |  | There was some other error performing the request | 
| 115 |  |  |  |  |  |  |  | 
| 116 |  |  |  |  |  |  | =item * ElasticSearch::Error::Conflict | 
| 117 |  |  |  |  |  |  |  | 
| 118 |  |  |  |  |  |  | There was a versioning conflict while performing an index/create/delete | 
| 119 |  |  |  |  |  |  | operation.  C inherits from | 
| 120 |  |  |  |  |  |  | C. | 
| 121 |  |  |  |  |  |  |  | 
| 122 |  |  |  |  |  |  | The lastest version number is available as: | 
| 123 |  |  |  |  |  |  |  | 
| 124 |  |  |  |  |  |  | $error->{-vars}{current_version}; | 
| 125 |  |  |  |  |  |  |  | 
| 126 |  |  |  |  |  |  | =item * ElasticSearch::Error::Missing | 
| 127 |  |  |  |  |  |  |  | 
| 128 |  |  |  |  |  |  | Tried to get/delete a document or index that doesn't exist. | 
| 129 |  |  |  |  |  |  | C inherits from | 
| 130 |  |  |  |  |  |  | C. | 
| 131 |  |  |  |  |  |  |  | 
| 132 |  |  |  |  |  |  | =item * ElasticSearch::Error::NoServers | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  | No servers are available | 
| 135 |  |  |  |  |  |  |  | 
| 136 |  |  |  |  |  |  | =item * ElasticSearch::Error::JSON | 
| 137 |  |  |  |  |  |  |  | 
| 138 |  |  |  |  |  |  | There was an error parsing a JSON doc | 
| 139 |  |  |  |  |  |  |  | 
| 140 |  |  |  |  |  |  | =item * ElasticSearch::Error::Internal | 
| 141 |  |  |  |  |  |  |  | 
| 142 |  |  |  |  |  |  | An internal error - you shouldn't see these | 
| 143 |  |  |  |  |  |  |  | 
| 144 |  |  |  |  |  |  | =back | 
| 145 |  |  |  |  |  |  |  | 
| 146 |  |  |  |  |  |  | =head1 LICENSE AND COPYRIGHT | 
| 147 |  |  |  |  |  |  |  | 
| 148 |  |  |  |  |  |  | Copyright 2010 - 2011 Clinton Gormley. | 
| 149 |  |  |  |  |  |  |  | 
| 150 |  |  |  |  |  |  | This program is free software; you can redistribute it and/or modify it | 
| 151 |  |  |  |  |  |  | under the terms of either: the GNU General Public License as published | 
| 152 |  |  |  |  |  |  | by the Free Software Foundation; or the Artistic License. | 
| 153 |  |  |  |  |  |  |  | 
| 154 |  |  |  |  |  |  | See http://dev.perl.org/licenses/ for more information. | 
| 155 |  |  |  |  |  |  |  | 
| 156 |  |  |  |  |  |  |  | 
| 157 |  |  |  |  |  |  | =cut | 
| 158 |  |  |  |  |  |  |  | 
| 159 |  |  |  |  |  |  | 1; | 
| 160 |  |  |  |  |  |  |  |