NAME

VPNDetection::Error - why a request failed

SYNOPSIS

my $result = eval { $client->lookup('1.1.1.1') };
if (my $err = $@) {
    die $err unless ref $err && $err->isa('VPNDetection::Error');
    warn $err->kind, ': ', $err->message;
    warn 'worth retrying' if $err->retryable;
}

DESCRIPTION

Every failure raised by this library is one of these objects. It stringifies to its message, so warn $@ and die $@ read as they would with an ordinary string exception.

METHODS

kind

One of bad_request, unauthorized, forbidden, rate_limited, quota_exceeded, server_error or network.

rate_limited and quota_exceeded both arrive as HTTP 429 and are not the same thing. A rate limit is the API protecting itself, carries Retry-After, and retrying works. A spent quota carries no such header, and retrying will not help until the window rolls over or the limit is raised. The header is the only thing that separates them.

message

The API's explanation, or a fallback naming the status.

status

The HTTP status, or undef for a transport failure.

retry_after

Seconds to wait, when the API said so.

retryable

Whether retrying this exact request could succeed. True for rate_limited, server_error and network, false for everything else.