Skip to content

if response from server is error, don't fail silently - #3

Merged
TheBuilderJR merged 1 commit into
telemetry-sh:mainfrom
kalradivyanshu:main
Sep 4, 2024
Merged

TheBuilderJR merged 1 commit into
telemetry-sh:mainfrom
kalradivyanshu:main

Conversation

@kalradivyanshu

@kalradivyanshu kalradivyanshu commented Sep 3, 2024 •

Copy link
Copy Markdown
Contributor

Right now if the server returns an error, the SDK fails silently, you have to manually check:

data = {"test": "test", "timestamp": datetime.now(timezone.utc).isoformat()}
response = await telemetry.log("test", data)
if response['status'] == 'error':
    # failed, do something

now, the SDK will throw an error, with the response['message'] if the server returns an error.

data = {"test": "test", "timestamp": datetime.now(timezone.utc).isoformat()}
try:
   await telemetry.log("test", data)
except Exception as e:
   # failed, do something

Updated for both async and sync. Now JS and python SDK have same behaviour: telemetry-sh/telemetry#1

@TheBuilderJR
TheBuilderJR merged commit 8f167b1 into telemetry-sh:main Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants