summaryrefslogtreecommitdiff
path: root/ext/ffi/00_ffi.js
diff options
context:
space:
mode:
authorIan Bull <irbull@gmail.com>2024-09-04 00:23:19 -0700
committerGitHub <noreply@github.com>2024-09-04 09:23:19 +0200
commitcb454351d497a4387775f3c9d64114cb8b32c08d (patch)
tree252e1dc84de3d3048ae3d98f4713cbdb436c5226 /ext/ffi/00_ffi.js
parent1ec911f1734b5e7190cc65876c5f03011e592d7e (diff)
refactor(ext): align error messages (#25310)
Diffstat (limited to 'ext/ffi/00_ffi.js')
-rw-r--r--ext/ffi/00_ffi.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/ext/ffi/00_ffi.js b/ext/ffi/00_ffi.js
index 06caf7c6c..1475f8d3f 100644
--- a/ext/ffi/00_ffi.js
+++ b/ext/ffi/00_ffi.js
@@ -250,7 +250,7 @@ class UnsafePointer {
}
} else {
throw new TypeError(
- "Expected ArrayBuffer, ArrayBufferView or UnsafeCallbackPrototype",
+ `Cannot access pointer: expected 'ArrayBuffer', 'ArrayBufferView' or 'UnsafeCallbackPrototype', received ${typeof value}`,
);
}
if (pointer) {
@@ -335,7 +335,9 @@ function getTypeSizeAndAlignment(type, cache = new SafeMap()) {
const cached = cache.get(type);
if (cached !== undefined) {
if (cached === null) {
- throw new TypeError("Recursive struct definition");
+ throw new TypeError(
+ "Cannot get pointer size: found recursive struct",
+ );
}
return cached;
}
@@ -379,7 +381,7 @@ function getTypeSizeAndAlignment(type, cache = new SafeMap()) {
case "isize":
return [8, 8];
default:
- throw new TypeError(`Unsupported type: ${type}`);
+ throw new TypeError(`Cannot get pointer size, unsupported type: ${type}`);
}
}
@@ -395,7 +397,7 @@ class UnsafeCallback {
constructor(definition, callback) {
if (definition.nonblocking) {
throw new TypeError(
- "Invalid UnsafeCallback, cannot be nonblocking",
+ "Cannot construct UnsafeCallback: cannot be nonblocking",
);
}
const { 0: rid, 1: pointer } = op_ffi_unsafe_callback_create(
@@ -467,7 +469,7 @@ class DynamicLibrary {
const type = symbols[symbol].type;
if (type === "void") {
throw new TypeError(
- "Foreign symbol of type 'void' is not supported.",
+ "Foreign symbol of type 'void' is not supported",
);
}