-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathSum.pm
More file actions
42 lines (34 loc) · 743 Bytes
/
Sum.pm
File metadata and controls
42 lines (34 loc) · 743 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package t::JSON::RPC::Test::Handler::Sum;
use strict;
use Class::Accessor::Lite new => 1;
use base 'Exporter';
our @EXPORT_OK = qw( CUSTOM_ERROR_CODE );
use constant CUSTOM_ERROR_CODE => -32000;
sub blowup {
die "I blew up!";
}
sub sum {
my ($self, $params, $proc, @args) = @_;
$params ||= [];
my $sum = 0;
foreach my $p (@$params) {
$sum += $p;
}
return $sum;
}
sub tidy_error {
die {
message => "short description of the error",
data => "additional information about the error"
};
}
sub custom_error {
die {
code => CUSTOM_ERROR_CODE,
message => "short description of the error",
data => {
some => 'data'
}
};
}
1;