duneanalytics / dune-client

A framework for interacting with Dune Analytics' officially supported API service
Apache License 2.0
85 stars 22 forks source link

Handle `insert_table` errors #129

Closed couralex6 closed 4 months ago

couralex6 commented 5 months ago

Fix for issue #128

Attempting to resolve the issue of unhandled insert errors with a new dataclass InsertTableErrorResult which can handle the error field.

This is most likely not the most elegant way to handle this. I'm open to suggestions :)

bh2smith commented 5 months ago

I like the solution although it doesn't quite follow the pattern we're using everywhere else. If you check the api/execution.py file you'll see this common pattern of try catch key error and then raise of dune error. Realistically we should improve the error classifications, but it might be good to try to follow the similar pattern for now so we can find all the things that need changing after improvements have been made.

I would also prefer to raise here instead of returning something that needs to be matched on. At least until the whole library is working that way.

couralex6 commented 4 months ago

@bh2smith throwing a DuneError when insert failed. I'm using DuneError, but we could also create a new Error type for the tables endpoint. lmk what you think

bh2smith commented 4 months ago

Looks good for now! I think improving error handling as a whole could be reserved for a follow up PR. let's get this in for now and address that separately. Let me know if you're happy with this and we can get it released.