Authen-U2F-Tester

 view release on metacpan or  search on metacpan

lib/Authen/U2F/Tester/Error.pm  view on Meta::CPAN

#
# 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



( run in 0.520 second using v1.01-cache-2.11-cpan-39bf76dae61 )