ember-optional-features
ember-optional-features copied to clipboard
Fix isFeatureEnabled to handle unknown features gracefully
Previously, calling isFeatureEnabled with an unknown feature name would throw "Cannot read properties of undefined (reading 'default')". This change makes isFeatureEnabled emit a warning and return null instead, preventing the exception.
Changes
-
index.js: Add guard inisFeatureEnabledto warn and returnnullfor unknown features instead of throwing -
tests/optional-features-test.js: Add test forisFeatureEnabledwith unknown features
Behavior
When calling isFeatureEnabled('unknown-feature'):
Warning: Unknown feature "unknown-feature" passed to isFeatureEnabled
Returns null instead of throwing.
The original behavior for config file validation is preserved - unknown features in config/optional-features.json still throw an error as expected.
Original prompt
This addon throws an expection when a feature is set that it doesn't know about. Make it output a warning but not fail in that case.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.