redis / go-redis

Redis Go client
https://redis.uptrace.dev
BSD 2-Clause "Simplified" License
19.81k stars 2.34k forks source link

Avoid using panic in Redis Commands #2834

Open ofekshenawa opened 8 months ago

ofekshenawa commented 8 months ago

In various functions within the go-redis library, there is a use of panic to handle cases. Using panic for this purpose is not in line with Go's idiomatic error handling and can result in unexpected program termination.

Suggested Improvement: Replace occurrences of panic with a more idiomatic error return approach. This allows users to handle argument validation errors gracefully through error checks and aligns with Go's standard error handling practices.

SoulPancake commented 8 months ago

Can you illustrate an example of how we can solve this? I would like to help with this @ofekshenawa

mushsoooup commented 8 months ago

Can you illustrate an example of how we can solve this? I would like to help with this @ofekshenawa

By using a middleware to capture panics and return as error perhaps.