Closed Bug 981768 Opened 10 years ago Closed 10 years ago

ModuleNotFoundError ignores try/catch

Categories

(Add-on SDK Graveyard :: General, defect)

x86_64
All
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: grobinson, Unassigned)

Details

Testing on Nightly: 30.0a1 (2014-03-05)
Add-on SDK: 1.15 (current release)

If I try to require a module that does not exist in the current version of the Jetpack API, I get a ModuleNotFoundError. Unexpectedly, this error causes cfx run to crash with the following traceback, even if the require statement is wrapped in a try/catch:

~/code/lightbeam $ cfx run -b ~/firefox-nightly/firefox
ModuleNotFoundError: unable to satisfy: require(sdk/ui/button/action) from
  /home/garrett/code/lightbeam/lib/ui.js:11:
Looked for it in:
  /home/garrett/code/lightbeam/lib/sdk/ui/button/action.js
  /home/garrett/addon-sdk-1.15/lib/sdk/ui/button/action.js
  /home/garrett/code/lightbeam/lib/sdk/ui/button/action.js

Here's the code that's trying to load button/action: https://github.com/mozilla/lightbeam/blob/master/lib/ui.js#L11

Expected behavior: the ModuleNotFoundError is an exception, which is caught by the try statement, and the code in the catch block is run.
So, this is not an error thrown while loading the non-existing module by the SDK, it's an error thrown by cfx trying to package an extension that requires a non-existing module. so basically, this is thrown in python land, and your JS try/catch doesn't count.

the solution is to either:
a) wait for SDK 1.16 to be released RSN
b) use cfx master branch from github (which includes australis modules)
c) work around the cfx with code like
    
    let buttonModule = 'sdk/ui/button/action';
    const { ActionButton } = require(buttonModule);

in any case, we will be releasing 1.16 any day now, and then retiring cfx altogether, so this is a WONTFIX..
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.