Skip to content

Commit 97422fc

Browse files
committed
Update core functions to raise typed errors
1 parent d528be7 commit 97422fc

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/onepassword/core.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import json
22
import platform
33

4+
from onepassword.errors import raise_typed_exception
5+
46

57
machine_arch = platform.machine().lower()
68

@@ -16,17 +18,26 @@
1618

1719
# InitClient creates a client instance in the current core module and returns its unique ID.
1820
async def _init_client(client_config):
19-
return await core.init_client(json.dumps(client_config))
21+
try:
22+
return await core.init_client(json.dumps(client_config))
23+
except Exception as e:
24+
raise_typed_exception(e)
2025

2126

2227
# Invoke calls specified business logic from the SDK core.
2328
async def _invoke(invoke_config):
24-
return await core.invoke(json.dumps(invoke_config))
29+
try:
30+
return await core.invoke(json.dumps(invoke_config))
31+
except Exception as e:
32+
raise_typed_exception(e)
2533

2634

2735
# Invoke calls specified business logic from the SDK core.
2836
def _invoke_sync(invoke_config):
29-
return core.invoke_sync(json.dumps(invoke_config))
37+
try:
38+
return core.invoke_sync(json.dumps(invoke_config))
39+
except Exception as e:
40+
raise_typed_exception(e)
3041

3142

3243
# ReleaseClient releases memory in the SDK core associated with the given client ID.

0 commit comments

Comments
 (0)