diff --git a/async-nats/src/client.rs b/async-nats/src/client.rs index 5138d839b..ab653af97 100644 --- a/async-nats/src/client.rs +++ b/async-nats/src/client.rs @@ -157,7 +157,7 @@ impl Client { /// # Examples /// ``` /// # #[tokio::main] - /// # async fn main() -> std::io::Result<()> { + /// # async fn main() -> Result<(), async_nats::Error> { /// # let mut nc = async_nats::connect("demo.nats.io").await?; /// let reply = nc.new_inbox(); /// let rsub = nc.subscribe(reply).await?; @@ -172,11 +172,11 @@ impl Client { &self, subject: String, queue_group: String, - ) -> Result { + ) -> Result { self._subscribe(subject, Some(queue_group)).await } - pub async fn subscribe(&self, subject: String) -> Result { + pub async fn subscribe(&self, subject: String) -> Result { self._subscribe(subject, None).await } @@ -187,7 +187,7 @@ impl Client { &self, subject: String, queue_group: Option, - ) -> Result { + ) -> Result { let sid = self.next_subscription_id.fetch_add(1, Ordering::Relaxed); let (sender, receiver) = mpsc::channel(self.subscription_capacity); @@ -198,8 +198,7 @@ impl Client { queue_group, sender, }) - .await - .unwrap(); + .await?; Ok(Subscriber::new(sid, self.sender.clone(), receiver)) } diff --git a/async-nats/src/lib.rs b/async-nats/src/lib.rs index 67df36622..2fc07e9cb 100644 --- a/async-nats/src/lib.rs +++ b/async-nats/src/lib.rs @@ -90,7 +90,7 @@ //! # use std::time::Instant; //! //! # #[tokio::main] -//! # async fn main() -> Result<(), Box> { +//! # async fn main() -> Result<(), async_nats::Error> { //! let client = async_nats::connect("demo.nats.io").await?; //! //! let mut subscriber = client.subscribe("foo".into()).await.unwrap(); @@ -930,7 +930,7 @@ impl Subscriber { /// # Examples /// ``` /// # #[tokio::main] - /// # async fn main() -> Result<(), Box> { + /// # async fn main() -> Result<(), async_nats::Error> { /// let client = async_nats::connect("demo.nats.io").await?; /// /// let mut subscriber = client.subscribe("foo".into()).await?;