~percona-toolkit-dev/percona-toolkit/pt-stalk-sleep-collect-option

« back to all changes in this revision

Viewing changes to lib/Percona/WebAPI/Exception/Resource.pm

  • Committer: Daniel Nichter
  • Date: 2013-06-19 21:23:55 UTC
  • mfrom: (582.1.5 release-2.2.3)
  • Revision ID: daniel@percona.com-20130619212355-nf6bmx23j3b76afe
Tags: 2.2.3
Merge release-2.2.3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# This program is copyright 2012-2013 Percona Inc.
 
2
# Feedback and improvements are welcome.
 
3
#
 
4
# THIS PROGRAM IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
 
5
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 
6
# MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
7
#
 
8
# This program is free software; you can redistribute it and/or modify it under
 
9
# the terms of the GNU General Public License as published by the Free Software
 
10
# Foundation, version 2; OR the Perl Artistic License.  On UNIX and similar
 
11
# systems, you can issue `man perlgpl' or `man perlartistic' to read these
 
12
# licenses.
 
13
#
 
14
# You should have received a copy of the GNU General Public License along with
 
15
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 
16
# Place, Suite 330, Boston, MA  02111-1307  USA.
 
17
# ###########################################################################
 
18
# Percona::WebAPI::Exception::Resource package
 
19
# ###########################################################################
 
20
{
 
21
package Percona::WebAPI::Exception::Resource;
 
22
 
 
23
use Lmo;
 
24
use overload '""' => \&as_string;
 
25
use Data::Dumper;
 
26
 
 
27
has 'type' => (
 
28
   is       => 'ro',
 
29
   isa      => 'Str',
 
30
   required => 1,
 
31
);
 
32
 
 
33
has 'link' => (
 
34
   is       => 'ro',
 
35
   isa      => 'Str',
 
36
   required => 1,
 
37
);
 
38
 
 
39
has 'data' => (
 
40
   is       => 'ro',
 
41
   isa      => 'ArrayRef',
 
42
   required => 1,
 
43
);
 
44
 
 
45
has 'error' => (
 
46
   is       => 'ro',
 
47
   isa      => 'Str',
 
48
   required => 1,
 
49
);
 
50
 
 
51
sub as_string {
 
52
   my $self = shift;
 
53
   chomp(my $error = $self->error);
 
54
   local $Data::Dumper::Indent    = 1;
 
55
   local $Data::Dumper::Sortkeys  = 1;
 
56
   local $Data::Dumper::Quotekeys = 0;
 
57
   return sprintf "Invalid %s resource from %s:\n\n%s\nError: %s\n\n",
 
58
      $self->type, $self->link, Dumper($self->data), $error;
 
59
}
 
60
 
 
61
no Lmo;
 
62
1;
 
63
}
 
64
# ###########################################################################
 
65
# End Percona::WebAPI::Exception::Resource package
 
66
# ###########################################################################