Catch SDK errors
The SDK throwsCybrLabsError with a stable code:
backendCode keeps the API’s own code, such as LAB_NOT_FOUND, for logs and case-specific handling. The error reference lists every code.
Answer the browser
Do not forwarderror.message or backendCode to the browser. toPublicError returns an HTTP status and a learner-safe body with fixed copy:
{ code, message, retryAfter? }. Any error that is not a CybrLabsError becomes a 500 with code: 'server_error'. httpStatusFor(error) returns only the status.
Show copy for specific cases
To vary the copy for specific situations, passincludeBackendCode:
backendCode when the code is on the PUBLIC_BACKEND_CODES list, such as LAB_ENDED or FLAG_REQUIRED. Other codes are left out. The error reference lists them.
Limits
rate_limited includes retryAfter in seconds when the API provides it. Show the wait in your interface. The rate limit guide explains the limits.
concurrency_limited means your organization has too many labs running. activeCount and limit give the numbers. Retrying at once does not free a slot.
Organization billing
subscription_required means your organization has no active subscription. billing_limit_reached means it reached its billing cap. The learner cannot fix either one, and retrying does not help. Show that labs are temporarily unavailable and alert whoever manages your Cybr account. toPublicError answers both with 403 and that copy.
Retries
The SDK retries GET requests after network errors, timeouts, server errors, and short rate limits. POST and DELETE requests retry only rate-limit refusals. The client reference has the details.Ambiguous writes
Atimeout or network_error on a POST is ambiguous. The server may have acted before the connection failed, and the API has no idempotency key. Check before repeating:
Cancellation
Every network method accepts asignal. Most take it in a final options argument:
aborted. It does not undo a request the server already accepted, and it does not end a deployment.