1
0

More precise error messages

This commit is contained in:
Jon Michael Aanes 2024-10-01 16:18:46 +02:00
parent 4a9f0fba8f
commit 7b9c7f04e7

View File

@ -76,9 +76,16 @@ class FavroClient:
session: requests.Session | None = None, session: requests.Session | None = None,
read_only=True, read_only=True,
): ):
assert favro_org_id is not None # Check arguments
assert favro_username is not None if not isinstance(favro_org_id, str):
assert favro_password is not None msg = f'favro_org_id must be str, but was {type(favro_org_id)}'
raise TypeError(msg)
if not isinstance(favro_username, str):
msg = f'favro_username must be str, but was {type(favro_username)}'
raise TypeError(msg)
if not isinstance(favro_password, str):
msg = f'favro_password must be str, but was {type(favro_password)}'
raise TypeError(msg)
# Setup session # Setup session
self.session = session or requests.Session() self.session = session or requests.Session()
@ -172,7 +179,7 @@ class FavroClient:
response = self.session.get(URL_GET_TAG.format(tag_id=tag_id.raw_id)) response = self.session.get(URL_GET_TAG.format(tag_id=tag_id.raw_id))
return TagInfo.from_json(response.json()) return TagInfo.from_json(response.json())
def get_custom_field(self, tag_id: CustomFieldId) -> CustomFieldInfo: def get_custom_field(self, custom_field_id: CustomFieldId) -> CustomFieldInfo:
response = self.session.get( response = self.session.get(
URL_GET_CUSTOM_FIELD.format(custom_field_id=custom_field_id.raw_id), URL_GET_CUSTOM_FIELD.format(custom_field_id=custom_field_id.raw_id),
) )