google-apis-rs / google-cloud-rs

Asynchronous Rust bindings for Google Cloud Platform APIs.
176 stars 48 forks source link

Pub/Sub `Subscription`'s `receive` method can panic #56

Open SolarLiner opened 3 years ago

SolarLiner commented 3 years ago

Right now, using receive and receive_with_options panics on any error (for example, loss of network or socket unexpectedly closed), preventing graceful handling of them. Furthermore, it is impossible to use catch_unwind as the Subscription type is not unwind-safe.

It would make more sense to return a Result and let the library user deal with the handling (or revert to old behavior via .unwrap()/.except()).