ianklatzco / atprototools

easy-to-use and ergonomic library for interacting with bluesky
MIT License
62 stars 11 forks source link

Exception classes #33

Open Jxck-S opened 1 year ago

Jxck-S commented 1 year ago

Something I believe I need to work on is exception classes. The reason I bring this up is. Lately, I was getting 400's turns out BlueSky has an image size limit. {"error":"BlobTooLarge","message":"This file is too large. It is 1.1MB, but the maximum size is 976.56KB."} The easiest thing to do I believe, is a generic ATProtoException class then raise it whenever error is present in the JSON response. raise ATProtoException (rsp.json()['error']). I'm assuming we should also raise for generic HTTP/connection errors. Let me know if you would like this.

MarshalX commented 1 year ago

Hi! This is how you can deal with it in atproto SDK

In the exception, you have access to the Response instance that includes the response status code, response headers, and content! Content could be automatically parsed into XrpcError!

image
Jxck-S commented 1 year ago

Hi! This is how you can deal with it in atproto SDK

In the exception, you have access to the Response instance that includes the response status code, response headers, and content! Content could be automatically parsed into XrpcError!

image

I was going to say I wanted to stick with atprototools as I already integrated it. But your project has much more work so I'll likely switch to it.