File Coverage

blib/lib/WebService/Mattermost/Role/Returns.pm
Criterion Covered Total %
statement 7 7 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod 1 1 100.0
total 10 10 100.0


line stmt bran cond sub pod time code
1             package WebService::Mattermost::Role::Returns;
2              
3             # ABSTRACT: Standard returns for user-facing subroutines.
4              
5 9     9   21113 use Moo::Role;
  9         21  
  9         58  
6              
7             ################################################################################
8              
9             sub error_return {
10 4     4 1 16829     my $self = shift;
11 4         10     my $error = shift;
12              
13 4         19     $error = sprintf '%s. No API query was made.', $error;
14              
15 4         33     return { error => 1, message => $error };
16             }
17              
18             ################################################################################
19              
20             1;
21              
22             __END__
23            
24             =pod
25            
26             =encoding UTF-8
27            
28             =head1 NAME
29            
30             WebService::Mattermost::Role::Returns - Standard returns for user-facing subroutines.
31            
32             =head1 VERSION
33            
34             version 0.26
35            
36             =head1 DESCRIPTION
37            
38             Common structures for return values.
39            
40             =head2 METHODS
41            
42             =over 4
43            
44             =item C<error_return()>
45            
46             Return an unsuccessful response with an error message.
47            
48             return $self->error_return('Error here');
49            
50             # \{
51             # error => 1,
52             # message => 'Error here. No API query was made.',
53             # }
54            
55             =back
56            
57             =head1 AUTHOR
58            
59             Mike Jones <mike@netsplit.org.uk>
60            
61             =head1 COPYRIGHT AND LICENSE
62            
63             This software is Copyright (c) 2020 by Mike Jones.
64            
65             This is free software, licensed under:
66            
67             The MIT (X11) License
68            
69             =cut
70