File: Error.pm

package info (click to toggle)
libauthen-u2f-tester-perl 0.03-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 176 kB
  • sloc: perl: 384; makefile: 2
file content (128 lines) | stat: -rw-r--r-- 2,674 bytes parent folder | download
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#
# This file is part of Authen-U2F-Tester
#
# This software is copyright (c) 2017 by Michael Schout.
#
# This is free software; you can redistribute it and/or modify it under
# the same terms as the Perl 5 programming language system itself.
#
package Authen::U2F::Tester::Error;
$Authen::U2F::Tester::Error::VERSION = '0.03';
# ABSTRACT: Authen::U2F::Tester Error Response

use Moose;
use MooseX::AttributeShortcuts;
use MooseX::SingleArg;

use Authen::U2F::Tester::Const ':all';
use namespace::autoclean;


has error_code => (is => 'ro', isa => 'Int', required => 1);


has error_message => (is => 'lazy', isa => 'Str');

single_arg 'error_code';


sub is_success { 0 }

sub _build_error_message {
    my $self = shift;

    my %errors = (
        OTHER_ERROR               => 'Other Error',
        BAD_REQUEST               => 'Bad Request',
        CONFIGURATION_UNSUPPORTED => 'Configuration Unsupported',
        DEVICE_INELIGIBLE         => 'Device Ineligible',
        TIMEOUT                   => 'Timeout');
}

__PACKAGE__->meta->make_immutable;

__END__

=pod

=head1 NAME

Authen::U2F::Tester::Error - Authen::U2F::Tester Error Response

=head1 VERSION

version 0.03

=head1 SYNOPSIS

 $r = $tester->register(...);

 # or

 $r = $tester->sign(...);

 unless ($r->is_success) {
     print $r->error_code;
     print $r->error_message;
 }

=head1 DESCRIPTION

This object is returned from L<Authen::U2F::Tester> sign or register requests
if the request resulted in an error.

=head1 METHODS

=head2 new(int)

Single arg constructor.  Argument is a U2F error code.  See
L<Authen::U2F::Tester::Const> for constants that should be used for this.

=head2 error_code(): int

Get the error code

=head2 error_message(): string

Get the error message

=head2 is_success(): bool

Returns false as this object is only returned for errors.

=head1 SEE ALSO

=over 4

=item *

L<Authen::U2F::Tester>

=back

=head1 SOURCE

The development version is on github at L<http://https://github.com/mschout/perl-authen-u2f-tester>
and may be cloned from L<git://https://github.com/mschout/perl-authen-u2f-tester.git>

=head1 BUGS

Please report any bugs or feature requests on the bugtracker website
L<https://github.com/mschout/perl-authen-u2f-tester/issues>

When submitting a bug or request, please include a test-file or a
patch to an existing test-file that illustrates the bug or desired
feature.

=head1 AUTHOR

Michael Schout <mschout@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by Michael Schout.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut