Skip to content

Errors

Every exception the package throws extends LSNepomuceno\LaravelAutentique\Exceptions\AutentiqueException, so one catch covers all of them. Each subclass names one fault (0005).

Autentique reports most errors with HTTP 200

Only a rejected token (401) and a rate limit (429) arrive as HTTP statuses. Everything else arrives with HTTP 200, as an errors array beside data, and the package treats that array as a failure even when data is partly filled. You never check a response for errors yourself: a method that returns, succeeded.

What can be thrown

ExceptionWhenSafe to send again?
Unauthenticatedthe token is missing, wrong, expired or revoked (401, or the code unauthorized)after fixing the token
InsufficientScopean OAuth token lacks the scope the operation needs (Unauthorized with 200)after authorizing again with the scope
OAuthFailedan OAuth step failed; $error carries the OAuth codesee OAuth
RateLimitedAutentique refused the request (429) and the configured retries were spentyes, after $retryAfter seconds
ValidationFaileda value was refused; the codes are per fieldafter fixing the value
ResendThrottledevery signature asked to be resent was resent too recently; nothing was sentyes, later
NotFoundthe document, folder or signature does not exist, or is not visible to the token's ownerno
GraphQLErrorany other error Autentique reported, with its code when the package knows itdepends on the code
TransportFailedthe connection failed or timed out, or the answer was not GraphQL (a 5xx, a proxy page)only if the operation is safe to repeat
MissingTokenno token is configured; nothing was sentafter configuring it
MissingOAuthCredentialsOAuth is used without a client id, secret or redirect URIafter configuring them
MissingWebhookSecreta webhook arrived and no secret is configured to verify itafter configuring it
InvalidInputa value the package refused before sending, because Autentique documents it would refuse or silently change itafter fixing the value
InvalidOperationan operation file is missing or broken; a defect in the packageno, report it
UnexpectedResponseAutentique answered without a field the package cannot do without; the API and the package disagree about the schemano, report it

Unauthenticated, InsufficientScope, OAuthFailed, RateLimited, ValidationFailed, ResendThrottled, NotFound, GraphQLError and TransportFailed extend RequestFailed, and carry:

Property
$operationthe operation's name, createDocument
$statusthe HTTP status, when there was one
$requestIdAutentique's X-Attq-Request-Id, worth quoting to their support
$errorsevery entry of errors, as Data\ApiError, not only the first

Validation

php
use LSNepomuceno\LaravelAutentique\Exceptions\ValidationFailed;

try {
    // …
} catch (ValidationFailed $exception) {
    $exception->messages();
    // ['folder.name' => ["Can't have less than 3 characters."]]

    foreach ($exception->violations() as $violation) {
        $violation->field;      // 'folder.name'
        $violation->code;       // ErrorCode::MustBeAtLeastCharacters
        $violation->parameter;  // '3'
    }
}

messages() is grouped the way Laravel's own validator groups errors, and each message follows the application's locale. English and Brazilian Portuguese ship, with Autentique's own wording where its documentation has one.

A code the package does not know still arrives, as $violation->rawCode, with $violation->code null.

Rate limits and retries

Autentique allows 10, 60 or 200 requests per minute per token, by plan. When it refuses one, the package waits and tries again, honouring Retry-After, up to autentique.retry.times times (2 by default). Only then does RateLimited reach you.

A timeout and a server error are never retried, because they may have been processed, and repeating createDocument after one can create a second billed document and send every signer a second request (0009).

The same caution applies to your own code: a queued job that sends documents should not retry itself blindly on TransportFailed. Look the document up first, or let a person decide.

php
use LSNepomuceno\LaravelAutentique\Exceptions\RateLimited;

public function handle(): void
{
    try {
        // …
    } catch (RateLimited $exception) {
        $this->release($exception->retryAfter ?? 60);
    }
}

Version 1.0.0. Released under the MIT License.