Skip to content
This repository was archived by the owner on Oct 9, 2023. It is now read-only.

Commit 61cb450

Browse files
authored
Fix incorrect usages of TypeDBClientException (#231)
## What is the goal of this PR? We fixed incorrect usages of TypeDBClientException leading to unhelpful error messages in some scenarios. ## What are the changes implemented in this PR? Fix incorrect usages of TypeDBClientException leading to unhelpful error messages in some scenarios.
1 parent f4487b8 commit 61cb450

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

typedb/api/connection/credential.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@
2323

2424
from typedb.common.exception import TypeDBClientException, CLUSTER_INVALID_ROOT_CA_PATH
2525

26+
2627
class TypeDBCredential:
2728

2829
def __init__(self, username: str, password: str, tls_root_ca_path: str = None):
2930
self._username = username
3031
self._password = password
3132

3233
if (tls_root_ca_path is not None and not path.exists(tls_root_ca_path)):
33-
raise TypeDBClientException(CLUSTER_INVALID_ROOT_CA_PATH.message(tls_root_ca_path))
34+
raise TypeDBClientException.of(CLUSTER_INVALID_ROOT_CA_PATH, tls_root_ca_path)
3435

3536
self._tls_root_ca_path = tls_root_ca_path
3637

typedb/common/exception.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
class TypeDBClientException(Exception):
2727

28-
def __init__(self, msg: Union["ErrorMessage", str], cause: Optional[BaseException], params: Any = None):
28+
def __init__(self, msg: Union["ErrorMessage", str], cause: BaseException = None, params: Any = None):
2929
if isinstance(msg, str):
3030
self.message = msg
3131
self.error_message = None

typedb/connection/cluster/user_manager.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def get(self, name: str) -> User:
6868
if (self.contains(name)):
6969
return _ClusterUser(self._client, name)
7070
else:
71-
raise TypeDBClientException(CLUSTER_USER_DOES_NOT_EXIST.message(name))
71+
raise TypeDBClientException.of(CLUSTER_USER_DOES_NOT_EXIST, name)
7272

7373

7474
class _UserManagerFailsafeTask(_FailsafeTask):

0 commit comments

Comments
 (0)