mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-11 13:40:07 +00:00
Skeleton bin/pt-agent and lib/Percona/WebAPI.
This commit is contained in:
44
lib/Percona/WebAPI/Exception/Request.pm
Normal file
44
lib/Percona/WebAPI/Exception/Request.pm
Normal file
@@ -0,0 +1,44 @@
|
||||
package Percona::WebAPI::Exception::Request;
|
||||
|
||||
use Mo;
|
||||
use overload '""' => \&as_string;
|
||||
|
||||
has 'method' => (
|
||||
is => 'ro',
|
||||
isa => 'Str',
|
||||
required => 1,
|
||||
);
|
||||
|
||||
has 'url' => (
|
||||
is => 'ro',
|
||||
isa => 'Str',
|
||||
required => 1,
|
||||
);
|
||||
|
||||
has 'content' => (
|
||||
is => 'ro',
|
||||
isa => 'Maybe[Str]',
|
||||
required => 0,
|
||||
);
|
||||
|
||||
has 'status' => (
|
||||
is => 'ro',
|
||||
isa => 'Int',
|
||||
required => 1,
|
||||
);
|
||||
|
||||
has 'error' => (
|
||||
is => 'ro',
|
||||
isa => 'Str',
|
||||
required => 1,
|
||||
);
|
||||
|
||||
sub as_string {
|
||||
my $self = shift;
|
||||
chomp(my $error = $self->error);
|
||||
$error =~ s/\n/ /g;
|
||||
return sprintf "Error: %s\nStatus: %d\nRequest: %s %s %s\n",
|
||||
$error, $self->status, $self->method, $self->url, $self->content || '';
|
||||
}
|
||||
|
||||
1;
|
Reference in New Issue
Block a user