line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::OATH::Server::Lite::Error; |
2
|
3
|
|
|
3
|
|
17469
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
99
|
|
3
|
3
|
|
|
3
|
|
10
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
66
|
|
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
846
|
use parent 'Class::Accessor::Fast'; |
|
3
|
|
|
|
|
500
|
|
|
3
|
|
|
|
|
13
|
|
6
|
3
|
|
|
3
|
|
7911
|
use Params::Validate qw(SCALAR); |
|
3
|
|
|
|
|
13652
|
|
|
3
|
|
|
|
|
609
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Net::OATH::Server::Lite::Error - Error class of Lite Server |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use Net::OATH::Server::Lite::Error; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# default error |
17
|
|
|
|
|
|
|
# HTTP/1.1 400 Bad Request |
18
|
|
|
|
|
|
|
# Content-Type: application/json;charset=UTF-8 |
19
|
|
|
|
|
|
|
# Cache-Control: no-store |
20
|
|
|
|
|
|
|
# Pragma: no-cache |
21
|
|
|
|
|
|
|
# |
22
|
|
|
|
|
|
|
# { |
23
|
|
|
|
|
|
|
# "error":"invalid_request" |
24
|
|
|
|
|
|
|
# } |
25
|
|
|
|
|
|
|
Net::OATH::Server::Lite::Error->throw() if ... |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# custom error |
28
|
|
|
|
|
|
|
# HTTP/1.1 404 Not Found |
29
|
|
|
|
|
|
|
# Content-Type: application/json;charset=UTF-8 |
30
|
|
|
|
|
|
|
# Cache-Control: no-store |
31
|
|
|
|
|
|
|
# Pragma: no-cache |
32
|
|
|
|
|
|
|
# |
33
|
|
|
|
|
|
|
# { |
34
|
|
|
|
|
|
|
# "error":"invalid_request", |
35
|
|
|
|
|
|
|
# "error_description":"invalid id" |
36
|
|
|
|
|
|
|
# } |
37
|
|
|
|
|
|
|
Net::OATH::Server::Lite::Error->throw( |
38
|
|
|
|
|
|
|
code => 404, |
39
|
|
|
|
|
|
|
description => q{invalid id}, |
40
|
|
|
|
|
|
|
) if ... |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw( |
45
|
|
|
|
|
|
|
code |
46
|
|
|
|
|
|
|
error |
47
|
|
|
|
|
|
|
description |
48
|
|
|
|
|
|
|
)); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub new { |
51
|
18
|
|
|
18
|
1
|
4009
|
my $class = shift; |
52
|
18
|
50
|
|
|
|
80
|
my @args = @_ == 1 ? %{$_[0]} : @_; |
|
0
|
|
|
|
|
0
|
|
53
|
18
|
|
|
|
|
525
|
my %params = Params::Validate::validate_with( |
54
|
|
|
|
|
|
|
params => \@args, |
55
|
|
|
|
|
|
|
spec => { |
56
|
|
|
|
|
|
|
code => { |
57
|
|
|
|
|
|
|
type => SCALAR, |
58
|
|
|
|
|
|
|
default => 400, |
59
|
|
|
|
|
|
|
optional => 1, |
60
|
|
|
|
|
|
|
}, |
61
|
|
|
|
|
|
|
error => { |
62
|
|
|
|
|
|
|
type => SCALAR, |
63
|
|
|
|
|
|
|
default => q{invalid_request}, |
64
|
|
|
|
|
|
|
optional => 1, |
65
|
|
|
|
|
|
|
}, |
66
|
|
|
|
|
|
|
description => { |
67
|
|
|
|
|
|
|
type => SCALAR, |
68
|
|
|
|
|
|
|
default => q{}, |
69
|
|
|
|
|
|
|
optional => 1, |
70
|
|
|
|
|
|
|
}, |
71
|
|
|
|
|
|
|
}, |
72
|
|
|
|
|
|
|
allow_extra => 0, |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
|
75
|
18
|
|
|
|
|
128
|
my $self = bless \%params, $class; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# TODO: more varidation |
78
|
|
|
|
|
|
|
|
79
|
18
|
|
|
|
|
130
|
return $self; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub throw { |
83
|
16
|
|
|
16
|
0
|
547
|
my ($class, %args) = @_; |
84
|
16
|
|
|
|
|
50
|
die $class->new(%args); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |