Skip to content

Commit

Permalink
expose Twirp errors to the public API
Browse files Browse the repository at this point in the history
  • Loading branch information
theomonnom committed Dec 14, 2023
1 parent c855f9a commit 1a2b25c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions livekit-api/livekit/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from livekit.protocol.room import *
from livekit.protocol.webhook import *

from .twirp_client import TwirpError, TwirpErrorCode
from .livekit_api import LiveKitAPI
from .access_token import VideoGrants, AccessToken, TokenVerifier
from .webhook import WebhookReceiver
Expand Down
2 changes: 1 addition & 1 deletion livekit-api/livekit/api/_service.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Dict
import aiohttp
from abc import ABC
from ._twirp_client import TwirpClient
from .twirp_client import TwirpClient
from .access_token import AccessToken, VideoGrants

AUTHORIZATION = "authorization"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,16 @@

class TwirpError(Exception):
def __init__(self, code: str, msg: str) -> None:
self.code = code
self.msg = msg
self._code = code
self._msg = msg

@property
def code(self) -> str:
return self._code

@property
def message(self) -> str:
return self._msg

class TwirpErrorCode:
CANCELED = "canceled"
Expand Down

0 comments on commit 1a2b25c

Please sign in to comment.