Skip to content

Commit cc1d4c4

Browse files
authored
expose Twirp errors to the public API (#123)
1 parent 84f0120 commit cc1d4c4

File tree

6 files changed

+20
-15
lines changed

6 files changed

+20
-15
lines changed

.github/workflows/build-api.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,10 @@ jobs:
2626

2727
- uses: actions/setup-python@v4
2828

29-
- name: Build wheel
29+
- name: Build wheel & sdist
3030
run: |
3131
pip3 install build wheel
32-
python3 -m build --wheel
33-
34-
- name: Build SDist
35-
run: pipx run build --sdist
32+
python3 -m build --wheel --sdist
3633
3734
- uses: actions/upload-artifact@v3
3835
with:

.github/workflows/build-protocol.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,10 @@ jobs:
2626

2727
- uses: actions/setup-python@v4
2828

29-
- name: Build wheel
29+
- name: Build wheel & sdist
3030
run: |
3131
pip3 install build wheel
32-
python3 -m build --wheel
33-
34-
- name: Build SDist
35-
run: pipx run build --sdist
32+
python3 -m build --wheel --sdist
3633
3734
- uses: actions/upload-artifact@v3
3835
with:

.github/workflows/build-rtc.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ jobs:
6363
with:
6464
submodules: true
6565

66-
- name: Build SDist
67-
run: pipx run build --sdist
66+
- name: Build sdist
67+
run: |
68+
pip3 install build
69+
python3 -m build --sdist
6870
6971
- uses: actions/upload-artifact@v3
7072
with:

livekit-api/livekit/api/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from livekit.protocol.room import *
2424
from livekit.protocol.webhook import *
2525

26+
from .twirp_client import TwirpError, TwirpErrorCode
2627
from .livekit_api import LiveKitAPI
2728
from .access_token import VideoGrants, AccessToken, TokenVerifier
2829
from .webhook import WebhookReceiver

livekit-api/livekit/api/_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import Dict
22
import aiohttp
33
from abc import ABC
4-
from ._twirp_client import TwirpClient
4+
from .twirp_client import TwirpClient
55
from .access_token import AccessToken, VideoGrants
66

77
AUTHORIZATION = "authorization"
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,16 @@
2323

2424
class TwirpError(Exception):
2525
def __init__(self, code: str, msg: str) -> None:
26-
self.code = code
27-
self.msg = msg
26+
self._code = code
27+
self._msg = msg
28+
29+
@property
30+
def code(self) -> str:
31+
return self._code
32+
33+
@property
34+
def message(self) -> str:
35+
return self._msg
2836

2937

3038
class TwirpErrorCode:

0 commit comments

Comments
 (0)