Replies: 1 comment
-
Hi @Think-M, From your snippet and the error ( Here are some pointers to handle exceptions properly in Return a proper Rust error type that converts into JS error Avoid returning error after Example pattern for error handling: #[op2(async)]
#[buffer]
pub async fn op_my_send(
state: Rc<RefCell<OpState>>,
#[buffer] data: JsBuffer,
) -> Result<Vec<u8>, deno_error::JsErrorBox> {
let result = match msg_type.as_str() {
"sum" => {
handle_sum(json_data, bin_data).await?;
// on success, return your data here
Ok(some_vec)
}
_ => Err(deno_error::JsErrorBox::from("Unsupported msg_type")),
};
result
} Here, Creating JS Errors manually use deno_core::error::type_error;
return Err(type_error("buffer Error")); The TL;DR
Try these adjustments and the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I try to return an exception through the following code:
The js reported an error:
When normal data is returned, there is no problem
Beta Was this translation helpful? Give feedback.
All reactions