clickhouse.rs icon indicating copy to clipboard operation
clickhouse.rs copied to clipboard

Provide more structural info in `Error::BadResponse`

Open loyd opened this issue 10 months ago • 1 comments

Use case

Sometimes, it's useful to detect and handle specific errors on the client side (e.g., TOO_MANY_SIMULTANEOUS_QUERIES). However, now Error::BadResponse contains only String, forcing users to use details.contains(code).

Describe the solution you'd like

Replace Error::BadResponse(String) with Error::BadResponse(BadResponseDetails) where BadResponseDetails contains code (numeric code), reason (string like TOO_MANY_SIMULTANEOUS_QUERIES) and message (the current String argument).

BadResponse is also used for HTTP errors, so we need to decide what should be stored in code and reason in this case. Another way is to divide BadResponse into two separate variants.

loyd avatar Feb 20 '25 07:02 loyd

I think we should separate the errors as ServerError and NetworkError in this case.

ozgurcancal avatar Oct 05 '25 20:10 ozgurcancal