Network & Transport Errors

Transport errors are failures that happen before the server can respond: connection refused or reset, request timeout, DNS lookup failure, TLS handshake failure. The SDK catches these at the HTTP-client boundary and re-emits them as a typed transport exception with a categorized errorType. The original error is preserved on the cause chain.

This means callers do not have to catch httpx.RequestError, HttpRequestException, Faraday::Error, GuzzleException, IOException, or net.Error separately. One catch block covers all transport-layer failures.

The errorType enum

ValueWhen the SDK uses it
connection_resetConnection refused, reset, or closed prematurely.
timeoutRead, write, or wall-clock deadline exceeded.
dns_failureCould not resolve the host.
tls_handshake_failedTLS / SSL handshake failed (certificate verify, protocol mismatch, etc.).
unknownCould not be classified into one of the above.

The transport exception always exposes the underlying error via the language-native cause-chain accessor.

Catching transport errors

import (
    "errors"
    "github.com/GetStream/getstream-go/v4"
)

_, err := client.DoSomething(ctx, ...)
if errors.Is(err, getstream.ErrTransport) {
    var streamErr *getstream.StreamError
    errors.As(err, &streamErr)
    // streamErr.ErrorType is one of connection_reset / timeout / dns_failure / tls_handshake_failed / unknown
    // errors.Unwrap(err) returns the underlying transport error
    if streamErr.ErrorType == "timeout" {
        // back off and try again later
    }
}

Distinguishing transport errors from API errors

Transport errors happen when no HTTP response was received. API errors happen when the server responded with a 4xx or 5xx. Catch them separately if you want to react differently:

_, err := client.DoSomething(ctx, ...)
if errors.Is(err, getstream.ErrApiResponse) {
    // server responded with a 4xx/5xx
} else if errors.Is(err, getstream.ErrTransport) {
    // network or transport-layer failure
}

Both transport and API exceptions inherit from the SDK's base exception. Catch that base type if you want to handle all SDK-emitted errors uniformly. See Exception Handling for the full class hierarchy.