*dreep.Error. Use the helper
functions to branch on the cases worth handling differently, without comparing status
codes yourself.
The Error type
errors.As when you need the raw fields:
Helpers
Errors raised before a request is sent, such as a missing
Filename or mutually exclusive
destination fields, are plain errors prefixed with dreep: rather than *dreep.Error.
Network failures and context cancellation wrap the underlying error, so
errors.Is(err, context.DeadlineExceeded) works as expected.
Plan limits
A 402 means the project hit a ceiling. When the API includes the detail,FeatureLimit
reports which feature, and the Error carries current usage against the cap:
What gets retried
Requests with a replayable body (PresignUpload, ListMedia, DeleteMedia, the folder,
preset and usage calls) are retried on a 429 or any 5xx: two retries by default, waiting 500ms before the first and doubling
from there. A Retry-After response header always overrides the computed delay.
Upload, RemoveBackground, UploadAndExtractText) are
never retried, because their bodies cannot be replayed. A failed upload can therefore
never store a duplicate asset. ConfirmUpload and ExtractText are sent once as well.
Retry those yourself when your own logic makes it safe. Connection failures are returned
immediately rather than retried.
UploadPresigned is the
one exception to “retry it yourself”: it retries the confirm step on 409 while the bytes
settle in storage.
Timeouts
The defaulthttp.Client has no global timeout. Bound each call with a context:
dreep.WithHTTPClient.