2024-05-25 12:06:50 +00:00
|
|
|
From e0cb884277200310eba263dcce5a7b1c4567bae6 Mon Sep 17 00:00:00 2001
|
2023-06-02 20:04:58 +00:00
|
|
|
From: Hood Chatham <roberthoodchatham@gmail.com>
|
|
|
|
Date: Fri, 19 May 2023 12:19:00 -0700
|
2024-06-19 00:10:22 +00:00
|
|
|
Subject: [PATCH 2/6] Add useful error when symbol resolution fails
|
2023-06-02 20:04:58 +00:00
|
|
|
|
|
|
|
Currently if symbol resolution fails, we get:
|
|
|
|
```js
|
|
|
|
TypeError: Cannot read properties of undefined (reading 'apply')
|
|
|
|
```
|
|
|
|
It is very hard for newcomers to Emscripten to recognize this as a
|
|
|
|
symbol resolution error. Even for people experienced with this message,
|
|
|
|
it has the annoyance that it doesn't give any hint as to which symbol
|
|
|
|
went missing.
|
|
|
|
|
|
|
|
This adds a descriptive error message with the name of the missing
|
|
|
|
symbol.
|
|
|
|
---
|
|
|
|
src/library_dylink.js | 3 +++
|
|
|
|
1 file changed, 3 insertions(+)
|
|
|
|
|
|
|
|
diff --git a/src/library_dylink.js b/src/library_dylink.js
|
2024-05-25 12:06:50 +00:00
|
|
|
index 1e67818a1..cea3ce05d 100644
|
2023-06-02 20:04:58 +00:00
|
|
|
--- a/src/library_dylink.js
|
|
|
|
+++ b/src/library_dylink.js
|
2024-05-25 12:06:50 +00:00
|
|
|
@@ -709,6 +709,9 @@ var LibraryDylink = {
|
2023-06-02 20:04:58 +00:00
|
|
|
var resolved;
|
2024-05-07 07:59:57 +00:00
|
|
|
stubs[prop] = (...args) => {
|
2024-01-23 12:18:42 +00:00
|
|
|
resolved ||= resolveSymbol(prop);
|
2023-06-02 20:04:58 +00:00
|
|
|
+ if (!resolved) {
|
|
|
|
+ throw new Error(`Dynamic linking error: cannot resolve symbol ${prop}`);
|
|
|
|
+ }
|
2024-05-07 07:59:57 +00:00
|
|
|
return resolved(...args);
|
2023-06-02 20:04:58 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
--
|
2024-05-07 07:59:57 +00:00
|
|
|
2.34.1
|
2023-06-02 20:04:58 +00:00
|
|
|
|