mirror of https://github.com/pyodide/pyodide.git
38 lines
1.2 KiB
Diff
38 lines
1.2 KiB
Diff
From e0cb884277200310eba263dcce5a7b1c4567bae6 Mon Sep 17 00:00:00 2001
|
|
From: Hood Chatham <roberthoodchatham@gmail.com>
|
|
Date: Fri, 19 May 2023 12:19:00 -0700
|
|
Subject: [PATCH 2/6] Add useful error when symbol resolution fails
|
|
|
|
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
|
|
index 1e67818a1..cea3ce05d 100644
|
|
--- a/src/library_dylink.js
|
|
+++ b/src/library_dylink.js
|
|
@@ -709,6 +709,9 @@ var LibraryDylink = {
|
|
var resolved;
|
|
stubs[prop] = (...args) => {
|
|
resolved ||= resolveSymbol(prop);
|
|
+ if (!resolved) {
|
|
+ throw new Error(`Dynamic linking error: cannot resolve symbol ${prop}`);
|
|
+ }
|
|
return resolved(...args);
|
|
};
|
|
}
|
|
--
|
|
2.34.1
|
|
|