Fix exposing full JS codec error.

In some cases tests would fail (I assume based on load / running
concurrent tests) without the full JS codec error.

Fixes #440.
This commit is contained in:
Orne Brocaar 2024-06-18 15:24:35 +01:00
parent 6b9f7a9ea1
commit c0b148fecb

View File

@ -59,7 +59,10 @@ pub async fn decode(
"#,
)
.context("Declare script")?;
let (buff, buff_promise) = buff.eval().context("Evalulate script")?;
let (buff, buff_promise) = buff
.eval()
.catch(&ctx)
.map_err(|e| anyhow!("JS error: {}", e))?;
buff_promise.finish()?;
let buff: rquickjs::Function = buff.get("Buffer")?;
@ -147,7 +150,10 @@ pub async fn encode(
"#,
)
.context("Declare script")?;
let (buff, buff_promise) = buff.eval().context("Evaluate script")?;
let (buff, buff_promise) = buff
.eval()
.catch(&ctx)
.map_err(|e| anyhow!("JS error: {}", e))?;
buff_promise.finish()?;
let buff: rquickjs::Function = buff.get("Buffer")?;