Skip to content

Errors & diagnostics

All SDK errors derive from ZeroTransferError. They carry:

FieldTypeNotes
namestringThe concrete subclass name (e.g. "ConnectionError").
codestringStable, machine-readable category (see below).
messagestringHuman-readable, redaction-safe.
detailsobject | undefinedStructured context (provider, host, path, byte counts, …).
causeunknownThe wrapped underlying error, when one exists.
retryablebooleanWhether a retry policy may safely retry this failure.

Protocol context (protocol, host, command, path, ftpCode, sftpCode) is attached when known, so application code never has to parse error messages.

Each subclass has a stable default code:

ClassDefault codeRaised when
ConnectionErrorZERO_TRANSFER_CONNECTION_ERRORTransport could not be opened or was lost mid-operation.
AuthenticationErrorZERO_TRANSFER_AUTHENTICATION_ERRORCredentials rejected.
AuthorizationErrorZERO_TRANSFER_AUTHORIZATION_ERRORAuthenticated but not allowed.
PathNotFoundErrorZERO_TRANSFER_PATH_NOT_FOUNDRemote path missing.
PathAlreadyExistsErrorZERO_TRANSFER_PATH_ALREADY_EXISTSDestination already exists.
PermissionDeniedErrorZERO_TRANSFER_PERMISSION_DENIEDServer returned 403 / 550.
TimeoutErrorZERO_TRANSFER_TIMEOUTDeadline or stall watchdog fired.
AbortErrorZERO_TRANSFER_ABORTEDCaller-initiated cancellation via AbortSignal.
ProtocolErrorZERO_TRANSFER_PROTOCOL_ERRORServer replied with malformed or unexpected data.
ParseErrorZERO_TRANSFER_PARSE_ERRORA server payload could not be parsed safely.
TransferErrorZERO_TRANSFER_TRANSFER_ERRORA transfer failed after all attempts were exhausted.
VerificationErrorZERO_TRANSFER_VERIFICATION_ERRORVerified hash didn’t match expected.
UnsupportedFeatureErrorZERO_TRANSFER_UNSUPPORTED_FEATUREOperation isn’t available on this provider.
ConfigurationErrorZERO_TRANSFER_CONFIGURATION_ERRORInvalid options or profile.
import { AuthenticationError, ZeroTransferError } from "@zero-transfer/sdk";
try {
await uploadFile({ ... });
} catch (err) {
if (err instanceof AuthenticationError) {
// never retry bad credentials, alert security
throw err;
}
if (err instanceof ZeroTransferError && err.retryable) {
return scheduleRetry(err);
}
throw err;
}

In practice you rarely branch on retryable yourself: createDefaultRetryPolicy already retries only failures the SDK marks retryable, with exponential backoff and jitter. See Transfers & sync for the full retry/timeout story.

ZeroTransferError.toJSON() runs details and command through secret redaction, so serialized errors never leak credentials, signed URLs, or raw protocol commands (the live details property stays unredacted for programmatic consumers). For arbitrary caught values, redactErrorForLogging converts anything thrown into a JSON-safe, secret-free record, and redactUrlForLogging strips userinfo and query strings (SigV4 signatures, SAS tokens) from URLs before they reach a log line.

import { redactErrorForLogging } from "@zero-transfer/sdk";
try {
await uploadFile({ ... });
} catch (err) {
logger.error("upload failed", redactErrorForLogging(err));
throw err;
}

runConnectionDiagnostics probes a profile and returns a structured report (DNS, TCP, TLS handshake, auth, capability advertisement). Pair it with summarizeClientDiagnostics for an at-a-glance view of every pooled session.

import { runConnectionDiagnostics, summarizeClientDiagnostics } from "@zero-transfer/sdk";
const report = await runConnectionDiagnostics({ client, profile });
console.log(report);
console.table(summarizeClientDiagnostics(client));

Both helpers respect profile redaction, so reports are safe to log or attach to support tickets.

See examples/diagnose-connection.ts for an end-to-end run.