From dd0acdad2f482de38f07dd0002267c572912da79 Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 12 Apr 2023 00:32:56 +0200 Subject: [PATCH] fix: map errors --- src/lib/opfactory.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lib/opfactory.rs b/src/lib/opfactory.rs index 8c92a8b..99ea1d9 100644 --- a/src/lib/opfactory.rs +++ b/src/lib/opfactory.rs @@ -99,26 +99,26 @@ impl AsyncFactory { pub async fn insert(&self, txt: String, pos: u64) -> Result { let (tx, rx) = oneshot::channel(); - self.ops.send(OpMsg::Exec(OpWrapper::Insert(txt, pos), tx)).await.unwrap(); - rx.await.unwrap() + self.ops.send(OpMsg::Exec(OpWrapper::Insert(txt, pos), tx)).await.map_err(|_| OTError)?; + rx.await.map_err(|_| OTError)? } pub async fn delete(&self, pos: u64, count: u64) -> Result { let (tx, rx) = oneshot::channel(); - self.ops.send(OpMsg::Exec(OpWrapper::Delete(pos, count), tx)).await.unwrap(); - rx.await.unwrap() + self.ops.send(OpMsg::Exec(OpWrapper::Delete(pos, count), tx)).await.map_err(|_| OTError)?; + rx.await.map_err(|_| OTError)? } pub async fn cancel(&self, pos: u64, count: u64) -> Result { let (tx, rx) = oneshot::channel(); - self.ops.send(OpMsg::Exec(OpWrapper::Cancel(pos, count), tx)).await.unwrap(); - rx.await.unwrap() + self.ops.send(OpMsg::Exec(OpWrapper::Cancel(pos, count), tx)).await.map_err(|_| OTError)?; + rx.await.map_err(|_| OTError)? } pub async fn process(&self, opseq: OperationSeq) -> Result { let (tx, rx) = oneshot::channel(); - self.ops.send(OpMsg::Process(opseq, tx)).await.unwrap(); - rx.await.unwrap() + self.ops.send(OpMsg::Process(opseq, tx)).await.map_err(|_| OTError)?; + rx.await.map_err(|_| OTError)? } }