Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize error type used in subscribe methods #524

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions async-nats/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
Expand All @@ -172,11 +172,11 @@ impl Client {
&self,
subject: String,
queue_group: String,
) -> Result<Subscriber, io::Error> {
) -> Result<Subscriber, Error> {
self._subscribe(subject, Some(queue_group)).await
}

pub async fn subscribe(&self, subject: String) -> Result<Subscriber, io::Error> {
pub async fn subscribe(&self, subject: String) -> Result<Subscriber, Error> {
self._subscribe(subject, None).await
}

Expand All @@ -187,7 +187,7 @@ impl Client {
&self,
subject: String,
queue_group: Option<String>,
) -> Result<Subscriber, io::Error> {
) -> Result<Subscriber, Error> {
let sid = self.next_subscription_id.fetch_add(1, Ordering::Relaxed);
let (sender, receiver) = mpsc::channel(self.subscription_capacity);

Expand All @@ -198,8 +198,7 @@ impl Client {
queue_group,
sender,
})
.await
.unwrap();
.await?;

Ok(Subscriber::new(sid, self.sender.clone(), receiver))
}
Expand Down
4 changes: 2 additions & 2 deletions async-nats/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
//! # use std::time::Instant;
//!
//! # #[tokio::main]
//! # async fn main() -> Result<(), Box<dyn Error>> {
//! # 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();
Expand Down Expand Up @@ -930,7 +930,7 @@ impl Subscriber {
/// # Examples
/// ```
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn std::error::Error>> {
/// # async fn main() -> Result<(), async_nats::Error> {
/// let client = async_nats::connect("demo.nats.io").await?;
///
/// let mut subscriber = client.subscribe("foo".into()).await?;
Expand Down