Skip to content
developers
Open TestCollab

Handle errors and asynchronous work

Handle HTTP failures explicitly and keep retries appropriate to the operation.

handle-errors.ts
import { createConfiguration, ResponseError, TestCasesApi } from '@testcollab/sdk';
const api = new TestCasesApi(createConfiguration(process.env.TESTCOLLAB_TOKEN!));
try {
const testCase = await api.getTestCase({ id: 456, project: 123 });
console.log(testCase.title);
} catch (error) {
if (error instanceof ResponseError) {
console.error('Request failed with HTTP status:', error.response.status);
// Handle authentication, permissions and missing records explicitly.
// Do not log request URLs: they may contain your API token.
} else {
throw error;
}
}
Status Check first
400 or 422 Request fields, IDs, ownership rules and validation details
401 API token and account region
403 Project membership and the permission needed for the operation
404 Resource ID, project scope and region
409 A conflicting state, retained record or in-progress operation
429 Wait before retrying and respect Retry-After when supplied
5xx A transient service error; retry reads with a bounded backoff

A timeout does not prove that a write failed. Before creating a second case or plan, check whether the first request succeeded. Avoid automatically repeating non-idempotent writes without a way to recognize the record you created.

Some bulk operations run in the background. The initial response confirms acceptance; it may not mean that every record has already changed.

When the next step depends on the new state, verify it through the corresponding resource read method. The plan workflow waits until the selected cases appear before assigning them.

For file-import and export workflows, use the completion/status contract documented for that particular operation. Do not treat a background job identifier as a completed download.