err before you use the result. When err is nil, the result holds the decoded response. When err is set, the result is empty and you should handle the failure.
What each return value holds
After you confirm
err == nil, use the result and optionally log resp.StatusCode.
Core error types
When Core rejects a request, the SDK wraps the failure in*blnkgo.ApiErrorResponse. Use errors.As to read structured fields instead of parsing message text.
The SDK also exports
blnkgo.AsApiErrorResponse(err) as a shortcut for errors.As.
How to handle errors
1
Check err
On every call, confirm
err is nil before you use the result.Error handling
2
Read the error detail
Use the field that matches the failure:
- Core rejection:
errors.Asmatches*ApiErrorResponse. ReadapiErr.ErrorDetail.Codefor logic. UseapiErr.Statuswhen you only need broad handling (401, 404, 409, 5xx). - SDK validation: plain
errorbefore any HTTP call. Readerr.Error()and fix the payload before retrying.
3
Handle transport failures
When the SDK cannot reach Core or the request times out, you get a network or timeout error from the HTTP client. Configure timeout and logging in your SDK client.
What Core sends on rejection
When Core rejects a request, the response body looks like this:404 Not Found
ApiErrorResponse. Read apiErr.ErrorDetail.Code in your app, not the message string. Message text can change between releases.
When Core returns only a flat "error" string with no error_detail, the SDK sets ErrorDetail.Code to "UNKNOWN".