Handle errors
Each exception from VerifyAsync is a VerifierException. Catch the exception types in this sequence:
var request = new VerificationRequest(payload);
try{ VerificationResult result = await verifier.VerifyAsync(request, cancellationToken);}catch (VerifierRejectedException){ // The payload could not be verified.}catch (VerifierException failure) when (failure.IsRetryable){ // Temporary. Send the same request again later.}catch (VerifierAuthException){ // Check the client ID, the client secret and the environment.}catch (VerifierException failure){ // Give the request ID and the idempotency key to Verifiabl support. logger.LogError( "Verification failed. Request ID: {RequestId}. Idempotency key: {IdempotencyKey}", failure.RequestId, failure.IdempotencyKey);}Exceptions
Section titled “Exceptions”| Exception | Cause | What to do |
|---|---|---|
VerifierRejectedException |
The payload could not be verified. Code is NOT_VERIFIED. |
The same payload gives the same result. Do not send it again. |
VerifierAuthException |
The SDK could not get an access token, or the API returned 401 or 403. |
If IsRetryable is true, try again later. If not, check the client ID, the client secret and the environment. |
VerifierServiceException |
The API returned an error. Code gives the error. |
If IsRetryable is true, try again later. If not, give RequestId to Verifiabl support. |
VerifierTimeoutException |
The call did not complete before the timeout. | If IsRetryable is true, try again later. The verification can be complete. |
VerifierTransportException |
The connection failed, or the SDK could not read a response. | If IsRetryable is true, try again later. If not, give RequestId to Verifiabl support. |
PayloadExtractionException |
Only from Verifiabl.Verifier.Extraction. The package did not read one payload from the document. It sent nothing to Verifiabl. |
Refer to Read payloads from documents. |
Use Code to identify an error. Do not compare the message text. This text can change.
VALIDATION_FAILED, PAYLOAD_TOO_LARGE and UNSUPPORTED_MEDIA_TYPE are not results about the payslip. Give RequestId to Verifiabl support.
A VerifierTransportException for a response that the SDK could not read is not retryable. It is not a result about the payslip. It has RequestId and Status, but not the response body.
Try again
Section titled “Try again”To try again, send the same VerificationRequest in 1 hour or less. The request sends the same idempotency key, so Verifiabl does not charge again for a verification that is complete. A new request is a new verification. Refer to Idempotency key.
IDEMPOTENCY_KEY_REUSED means that the key was sent with a different payslip, or was first sent more than 1 hour ago. Nothing was verified or charged. To verify the payload, make a new VerificationRequest.
The SDK checks the length of the text before it sends it. If the text is empty or longer than VerifierClient.MaxBarcodeLength (13,000 characters), the SDK throws VerifierRejectedException with the code NOT_VERIFIED. It does not send a request. Status is null.
If you cancel the call, the SDK throws OperationCanceledException, not a VerifierException. The verification can be complete. If you send it again, send the same request.
Not verified
Section titled “Not verified”A NOT_VERIFIED result means only that the payload could not be verified. A damaged scan, a payslip that is not registered, or a barcode from another product or environment gives the same result. The API does not give the cause.
If many payloads give NOT_VERIFIED, check Environment. A payslip registered in sandbox cannot be verified in production. A payslip registered in production cannot be verified in sandbox.
Request ID
Section titled “Request ID”RequestId is the ID of the API response. It is on VerificationResult and on each exception. If no API response was received, for example after a network failure, it is null. Give it to Verifiabl support if you need help with a verification.
Exception properties
Section titled “Exception properties”| Property | Description |
|---|---|
IsRetryable |
true if the same call can succeed later. |
RequestId |
The ID of the last API response. |
RetryAfter |
The wait that the API asked for, or null. If you put the failure in a queue, save the time to try again, not the wait. |
IdempotencyKey |
The idempotency key of the request. Give it when you ask Verifiabl about the verification or its charge. null if the SDK did not send a request. |
Code |
The error code. Not on VerifierTimeoutException or VerifierTransportException. |
Status |
The HTTP status code, or null if no API response was received. Not on VerifierTimeoutException. |
The exception message does not contain the payload or the payslip data.