新增 Zalo OA、Zoom Chat、Zulip 三个渠道扩展。 Zalo OA 渠道扩展主要模块:sidecar_client, config, gateway, outbound, streaming, pairing, security, auth, dedupe, directory, monitor, status, session, reactions, tools Zoom Chat 渠道扩展主要模块:config, gateway, webhook, outbound, streaming, pairing, security, crypto, dedupe, actions, media, mentions, monitor, status, session, reactions, threading Zulip 渠道扩展主要模块:client, config, gateway, outbound, streaming, pairing, security, monitor, status
44 lines
925 B
Python
44 lines
925 B
Python
from __future__ import annotations
|
|
|
|
|
|
class ZaloUserError(Exception):
|
|
pass
|
|
|
|
|
|
class ZaloUserAuthError(ZaloUserError):
|
|
pass
|
|
|
|
|
|
class ZaloUserConnectionError(ZaloUserError):
|
|
pass
|
|
|
|
|
|
class ZaloUserSendError(ZaloUserError):
|
|
pass
|
|
|
|
|
|
class ZaloUserQRExpiredError(ZaloUserAuthError):
|
|
pass
|
|
|
|
|
|
class ZaloUserQRDeclinedError(ZaloUserAuthError):
|
|
pass
|
|
|
|
|
|
class ZaloUserNotAuthenticatedError(ZaloUserAuthError):
|
|
pass
|
|
|
|
|
|
class ZaloUserWatchdogTimeoutError(ZaloUserConnectionError):
|
|
pass
|
|
|
|
|
|
def classify_http_error(status_code: int, body: str = "") -> ZaloUserError:
|
|
if status_code == 401:
|
|
return ZaloUserAuthError(f"Authentication failed: {body}")
|
|
if status_code == 403:
|
|
return ZaloUserAuthError(f"Access denied: {body}")
|
|
if 500 <= status_code < 600:
|
|
return ZaloUserConnectionError(f"Sidecar error ({status_code}): {body}")
|
|
return ZaloUserError(f"HTTP {status_code}: {body}")
|