mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-16 08:25:18 +02:00
fix: better error handling for telephony
This commit is contained in:
parent
87fc64d55c
commit
8c42866f80
5 changed files with 28 additions and 12 deletions
|
|
@ -7,6 +7,7 @@ import random
|
|||
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
||||
|
||||
import aiohttp
|
||||
from fastapi import HTTPException
|
||||
from loguru import logger
|
||||
|
||||
from api.enums import WorkflowRunMode
|
||||
|
|
@ -104,10 +105,12 @@ class CloudonixProvider(TelephonyProvider):
|
|||
"caller-id": from_number, # Required field
|
||||
}
|
||||
|
||||
# TODO: Cloudonix status callbacks are spammy, so commenting it out. Can send it to
|
||||
# some persistent logging system instead of transcational database.
|
||||
# Add status callback if workflow_run_id provided
|
||||
if workflow_run_id:
|
||||
callback_url = f"{backend_endpoint}/api/v1/telephony/cloudonix/status-callback/{workflow_run_id}"
|
||||
data["callback"] = callback_url
|
||||
# if workflow_run_id:
|
||||
# callback_url = f"{backend_endpoint}/api/v1/telephony/cloudonix/status-callback/{workflow_run_id}"
|
||||
# data["callback"] = callback_url
|
||||
|
||||
# Merge any additional kwargs
|
||||
data.update(kwargs)
|
||||
|
|
@ -153,8 +156,9 @@ class CloudonixProvider(TelephonyProvider):
|
|||
f" Request: POST {endpoint}\n"
|
||||
f" Payload: {json.dumps(data, indent=2)}"
|
||||
)
|
||||
raise Exception(
|
||||
f"Failed to initiate call via Cloudonix (HTTP {response_status}): {response_text}"
|
||||
raise HTTPException(
|
||||
status_code=response_status,
|
||||
detail=f"Failed to initiate call via Cloudonix (HTTP {response_status}): {response_text}",
|
||||
)
|
||||
|
||||
response_data = await response.json()
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import random
|
|||
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
||||
|
||||
import aiohttp
|
||||
from fastapi import HTTPException
|
||||
from loguru import logger
|
||||
from twilio.request_validator import RequestValidator
|
||||
|
||||
|
|
@ -98,7 +99,9 @@ class TwilioProvider(TelephonyProvider):
|
|||
async with session.post(endpoint, data=data, auth=auth) as response:
|
||||
if response.status != 201:
|
||||
error_data = await response.json()
|
||||
raise Exception(f"Failed to initiate call: {error_data}")
|
||||
raise HTTPException(
|
||||
status_code=response.status, detail=json.dumps(error_data)
|
||||
)
|
||||
|
||||
response_data = await response.json()
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import random
|
|||
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
||||
|
||||
import aiohttp
|
||||
from fastapi import HTTPException
|
||||
from loguru import logger
|
||||
|
||||
from api.enums import WorkflowRunMode
|
||||
|
|
@ -116,7 +117,10 @@ class VobizProvider(TelephonyProvider):
|
|||
if response.status != 201:
|
||||
error_data = await response.text()
|
||||
logger.error(f"Vobiz API error: {error_data}")
|
||||
raise Exception(f"Failed to initiate Vobiz call: {error_data}")
|
||||
raise HTTPException(
|
||||
status_code=response.status,
|
||||
detail=f"Failed to initiate Vobiz call: {error_data}",
|
||||
)
|
||||
|
||||
response_data = await response.json()
|
||||
logger.info(f"Vobiz API response: {response_data}")
|
||||
|
|
@ -133,8 +137,10 @@ class VobizProvider(TelephonyProvider):
|
|||
logger.error(
|
||||
f"No call ID found in Vobiz response. Available keys: {list(response_data.keys())}"
|
||||
)
|
||||
raise Exception(
|
||||
f"Vobiz API response missing call identifier. Response: {response_data}"
|
||||
raise HTTPException(
|
||||
status_code=response.status,
|
||||
detail=f"Vobiz API response missing call identifier. Response: {response_data}"
|
||||
f"Vobiz API response missing call identifier. Response: {response_data}",
|
||||
)
|
||||
|
||||
logger.info(f"Vobiz call initiated successfully. Call ID: {call_id}")
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
|||
|
||||
import aiohttp
|
||||
import jwt
|
||||
from fastapi import Response
|
||||
from fastapi import HTTPException, Response
|
||||
from loguru import logger
|
||||
|
||||
from api.enums import WorkflowRunMode
|
||||
|
|
@ -127,7 +127,10 @@ class VonageProvider(TelephonyProvider):
|
|||
response_data = await response.json()
|
||||
|
||||
if response.status != 201:
|
||||
raise Exception(f"Failed to initiate call: {response_data}")
|
||||
raise HTTPException(
|
||||
status_code=response.status,
|
||||
detail=f"Failed to initiate Vonage call: {response_data}",
|
||||
)
|
||||
|
||||
return CallInitiationResult(
|
||||
call_id=response_data["uuid"],
|
||||
|
|
|
|||
2
pipecat
2
pipecat
|
|
@ -1 +1 @@
|
|||
Subproject commit f999b70ffb3ba678aec1996f85a69fe13692d067
|
||||
Subproject commit 866bf1c5685e7fadf2af012d8769ebbc35297db0
|
||||
Loading…
Add table
Add a link
Reference in a new issue