-
Hello, I want to know that how to deal with errors (such as invalid path, file busy, etc.) inside module loader. Since it is defined as
is it right to return nullptr when some error occurs? I've tried before calling And what about JSModuleNormalizeFunc? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Yes, you should throw an exception and return NULL. I recently added some error handling for similar cases (when setting the meta object fails): ab48ede
Same thing. The default one can also fail in case of memory errors for example, and it will simply return NULL with the OOM exception thrown. |
Beta Was this translation helpful? Give feedback.
-
I took the liberty to convert this to a discussion. |
Beta Was this translation helpful? Give feedback.
-
Thank you for the answer. It seems I did the correct implementation. In addition, I noticed that in JS_LoadModuleInternal, we just check whether the module loader returns a NULL and go to fail without a This lead to a..(eh, UB? I dont know) problem, since JS_GetException now returns So I think it maybe need to review those cases caused by this change, or try to add the missing THROWs (feels difficult to collect all)? |
Beta Was this translation helpful? Give feedback.
The called function should be the one throwing the exception, then returning NULL.