mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 09:31:22 -05:00
fix(core): improve error on invalid op id (#13056)
This commit is contained in:
parent
83804f7c99
commit
34f05f673e
1 changed files with 17 additions and 2 deletions
|
@ -26,6 +26,11 @@ use v8::SharedArrayBuffer;
|
|||
use v8::ValueDeserializerHelper;
|
||||
use v8::ValueSerializerHelper;
|
||||
|
||||
const UNDEFINED_OP_ID_MSG: &str =
|
||||
"invalid op id: received `undefined` instead of an integer.
|
||||
This error is often caused by a typo in an op name, or not calling
|
||||
JsRuntime::sync_ops_cache() after JsRuntime initialization.";
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
pub static ref EXTERNAL_REFERENCES: v8::ExternalReferences =
|
||||
v8::ExternalReferences::new(&[
|
||||
|
@ -437,7 +442,12 @@ fn opcall_sync<'s>(
|
|||
{
|
||||
Ok(op_id) => op_id,
|
||||
Err(err) => {
|
||||
throw_type_error(scope, format!("invalid op id: {}", err));
|
||||
let msg = if args.get(0).is_undefined() {
|
||||
UNDEFINED_OP_ID_MSG.to_string()
|
||||
} else {
|
||||
format!("invalid op id: {}", err)
|
||||
};
|
||||
throw_type_error(scope, msg);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
@ -494,7 +504,12 @@ fn opcall_async<'s>(
|
|||
{
|
||||
Ok(op_id) => op_id,
|
||||
Err(err) => {
|
||||
throw_type_error(scope, format!("invalid op id: {}", err));
|
||||
let msg = if args.get(0).is_undefined() {
|
||||
UNDEFINED_OP_ID_MSG.to_string()
|
||||
} else {
|
||||
format!("invalid op id: {}", err)
|
||||
};
|
||||
throw_type_error(scope, msg);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue