Skip to content

Commit f2418ba

Browse files
committed
stream_to_json_array: return serde_json::Error
Rather than converting any serde errors to `anyhow::Error` (so that they can then be converted to `JsError`), just return them directly. We can't do handle the UTF8-decoding error the same way, but that shouldn't happen anyway, unless serde_json is buggy.
1 parent 11bbbd6 commit f2418ba

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/machine.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ impl OlmMachine {
979979
let me = self.inner.clone();
980980

981981
future_to_promise(async move {
982-
stream_to_json_array(pin!(
982+
Ok(stream_to_json_array(pin!(
983983
me.store()
984984
.export_room_keys_stream(|session| {
985985
let session = session.clone();
@@ -992,7 +992,7 @@ impl OlmMachine {
992992
})
993993
.await?,
994994
))
995-
.await
995+
.await?)
996996
})
997997
}
998998

@@ -1696,7 +1696,7 @@ pub(crate) async fn promise_result_to_future(
16961696
}
16971697
}
16981698

1699-
async fn stream_to_json_array<T, S>(mut stream: Pin<&mut S>) -> Result<String, anyhow::Error>
1699+
async fn stream_to_json_array<T, S>(mut stream: Pin<&mut S>) -> Result<String, serde_json::Error>
17001700
where
17011701
T: Serialize,
17021702
S: Stream<Item = T>,
@@ -1709,5 +1709,5 @@ where
17091709
}
17101710
seq.end()?;
17111711

1712-
Ok(String::from_utf8(stream_json)?)
1712+
Ok(String::from_utf8(stream_json).expect("serde_json generated invalid UTF8"))
17131713
}

0 commit comments

Comments
 (0)