lukaskollmer / objc

🔮 NodeJS ↔ Objective-C bridge (experimental)
MIT License
98 stars 20 forks source link

Unhelpful error message when framework not found #34

Closed hhas closed 2 years ago

hhas commented 2 years ago

The importFramework utility function throws an unhelpful error message when NSBundle.bundleWithPath_(path) returns null (e.g. because the path was invalid):

/Users/foo/node_modules/objc/src/util.js:25
  bundle.load();
TypeError: Cannot read properties of null (reading 'load')

I suggest inserting a null check before the bundle.load() line that throws a descriptive error:

  if (bundle === null) { throw Error(`Framework not found: '${path}'`); }
lukaskollmer commented 2 years ago

Yeah this seems like a good idea, I'll add that. Thanks for the feedback.

lukaskollmer commented 2 years ago

Done, fixed in 0.23.0