Error Handling
Catch and inspect SDK failures in Node.js and Python.
Both SDKs raise on non-2xx responses. A 204 No Content resolves to undefined
(Node) / None (Python) instead of raising.
import { BranofyVoiceSdk, VoiceApiError } from "@branofy/voice-sdk-node";
const voice = new BranofyVoiceSdk({
baseUrl: "https://api.branofy.cloud",
apiKey: process.env.BRANOFY_VOICE_API_KEY,
});
try {
await voice.calls.start("agt_missing", {
phone: "+919876543210",
name: "Priya Sharma",
});
} catch (err) {
if (err instanceof VoiceApiError) {
console.error(`Request failed (${err.status}): ${err.message}`);
console.error(err.details);
} else {
throw err;
}
}import requests
try:
client.start_call(agent_id="agt_missing", phone="+91...", name="Priya")
except requests.HTTPError as err:
print("Status:", err.response.status_code)
print("Body:", err.response.text)VoiceApiError (Node.js)
| Property | Type | Description |
|---|---|---|
status | number | HTTP status code of the failed response. |
message | string | Error message from the body, or the HTTP status text. |
details | unknown | The parsed JSON error body, when available. |
Status codes
| Status | Meaning |
|---|---|
400 | Malformed request or missing required fields. |
401 | Missing or invalid API key. |
404 | The referenced resource does not exist. |