| 1 | package WWW::Yandex::PDD::Error; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 2 | ▶ | use base "Exporter"; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 2 | ▶ | use constant { | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 2 | HTTP_ERROR => 'HTTP_ERROR', | |||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | NOT_AUTHENTICATED => 'NOT_AUTHENTICATED', | ||||||||||||||||||||
| 12 | INVALID_RESPONSE => 'INVALID_RESPONSE', | ||||||||||||||||||||
| 13 | REQUEST_FAILED => 'REQUEST_FAILED', | ||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | USER_NOT_FOUND => 'USER_NOT_FOUND', | ||||||||||||||||||||
| 16 | LOGIN_OCCUPIED => 'LOGIN_OCCUPIED', | ||||||||||||||||||||
| 17 | LOGIN_TOO_SHORT => 'LOGIN_TOO_SHORT', | ||||||||||||||||||||
| 18 | LOGIN_TOO_LONG => 'LOGIN_TOO_LONG', | ||||||||||||||||||||
| 19 | INVALID_LOGIN => 'INVALID_LOGIN', | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | INVALID_PASSWORD => 'INVALID_PASSWORD', | ||||||||||||||||||||
| 22 | PASSWORD_TOO_SHORT => 'PASSWORD_TOO_SHORT', | ||||||||||||||||||||
| 23 | PASSWORD_TOO_LONG => 'PASSWORD_TOO_LONG', | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | CANT_CREATE_ACCOUNT => 'CANT_CREATE_ACCOUNT', | ||||||||||||||||||||
| 26 | USER_LIMIT_EXCEEDED => 'USER_LIMIT_EXCEEDED', | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | NO_IMPORT_SETTINGS => 'NO_IMPORT_SETTINGS', | ||||||||||||||||||||
| 29 | SERVICE_ERROR => 'SERVICE_ERROR', | ||||||||||||||||||||
| 30 | UNKNOWN_ERROR => 'UNKNOWN_ERROR', | ||||||||||||||||||||
| 31 | 2 | }; | |||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 2 | my @ERR = qw( | |||||||||||||||||||
| 34 | NOT_AUTHENTICATED | ||||||||||||||||||||
| 35 | INVALID_RESPONSE | ||||||||||||||||||||
| 36 | REQUEST_FAILED | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | USER_NOT_FOUND | ||||||||||||||||||||
| 39 | LOGIN_OCCUPIED | ||||||||||||||||||||
| 40 | LOGIN_TOO_SHORT | ||||||||||||||||||||
| 41 | LOGIN_TOO_LONG | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | PASSWORD_TOO_SHORT | ||||||||||||||||||||
| 44 | PASSWORD_TOO_LONG | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | CANT_CREATE_ACCOUNT | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | USER_LIMIT_EXCEEDED | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | NO_IMPORT_SETTINGS | ||||||||||||||||||||
| 51 | NO_IMPORT_INFO | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | SERVICE_ERROR | ||||||||||||||||||||
| 54 | UNKNOWN_ERROR | ||||||||||||||||||||
| 55 | ); | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | 2 | my %ERR_R = ( | |||||||||||||||||||
| 58 | 'not authenticated' => NOT_AUTHENTICATED, | ||||||||||||||||||||
| 59 | 'not_authorized' => NOT_AUTHENTICATED, | ||||||||||||||||||||
| 60 | 'no_login' => INVALID_LOGIN, | ||||||||||||||||||||
| 61 | 'bad_login' => INVALID_LOGIN, | ||||||||||||||||||||
| 62 | 'no_user' => USER_NOT_FOUND, | ||||||||||||||||||||
| 63 | 'not_found' => USER_NOT_FOUND, | ||||||||||||||||||||
| 64 | 'user_not_found' => USER_NOT_FOUND, | ||||||||||||||||||||
| 65 | 'no such user registered' => USER_NOT_FOUND, | ||||||||||||||||||||
| 66 | 'occupied' => LOGIN_OCCUPIED, | ||||||||||||||||||||
| 67 | 'login_short' => LOGIN_TOO_SHORT, | ||||||||||||||||||||
| 68 | 'badlogin_length' => LOGIN_TOO_LONG, | ||||||||||||||||||||
| 69 | 'passwd-badpasswd' => INVALID_PASSWORD, | ||||||||||||||||||||
| 70 | 'passwd-tooshort' => PASSWORD_TOO_SHORT, | ||||||||||||||||||||
| 71 | 'passwd-toolong' => PASSWORD_TOO_LONG, | ||||||||||||||||||||
| 72 | 'hundred_users_limit' => USER_LIMIT_EXCEEDED, | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | 'no-passwd_cryptpasswd' => INVALID_PASSWORD, | ||||||||||||||||||||
| 75 | 'cant_create_account' => CANT_CREATE_ACCOUNT, | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | 'no_import_settings' => NO_IMPORT_SETTINGS, | ||||||||||||||||||||
| 78 | 'no import info on this user' => USER_NOT_FOUND, | ||||||||||||||||||||
| 79 | 'unknown' => REQUEST_FAILED, | ||||||||||||||||||||
| 80 | ); | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | 2 | our @EXPORT_OK = ( @ERR ); | |||||||||||||||||||
| 83 | 2 | our %EXPORT_TAGS = ( errors => [ @ERR ] ); | |||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | sub identify | ||||||||||||||||||||
| 86 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
identify: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 87 | 0 | ▶ | return $ERR_R{ [split(/,/, $_[0], 2)] -> [0] } || &REQUEST_FAILED; | ||||||||||||||||||
|
Condition0%0/3
$ERR_R{[split(/,/, $_[0], 2)]->[0]} || &REQUEST_FAILED
MC/DC0%0/2
$ERR_R{[split(/,/, $_[0], 2)]->[0]} || &REQUEST_FAILED
$ERR_R{[split(/,/, $_[0], 2)]->[0]}
&REQUEST_FAILED
Truth table0%0/3
A || B
A= $ERR_R{[split(/,/, $_[0], 2)]->[0]}B= &REQUEST_FAILED
| |||||||||||||||||||||
| 88 | } | ||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | =encoding utf8 | ||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | =head1 NAME | ||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | WWW::Yandex::PDD::Error - error messages handling for L<WWW::Yandex::PDD> | ||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | =head1 SYNOPSIS | ||||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | Normally there is no need to mess with this package. | ||||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | Unfortunately, Yandex API does not provide any description of error messages or even a list of possible messages. Please contact me at L<< <aluck@cpan.org> >> if you happen to stumble upon any messages that are not handled here. | ||||||||||||||||||||
| 102 | |||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | =head1 METHODS | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | =head2 identify | ||||||||||||||||||||
| 107 | my $error = WWW::Yandex::PDD::identify($error_message) | ||||||||||||||||||||
| 108 | |||||||||||||||||||||
| 109 | Takes Yandex error message, returns its type. | ||||||||||||||||||||
| 110 | |||||||||||||||||||||
| 111 | =cut | ||||||||||||||||||||
| 112 | |||||||||||||||||||||
| 113 | 2 | 1; | |||||||||||||||||||