Location
extension.js:20-22
Problem
const affirmations = await fetchAffirmations();
const randomNumber = Math.floor(Math.random() * affirmations.length);
vscode.window.showInformationMessage(affirmations[randomNumber].text);
If fetchAffirmations throws (network error) or the API returns an error object instead of an array, affirmations.length is undefined and .text throws a TypeError. This crashes extension activation, which means none of the commands register.
Suggested fix
try {
const affirmations = await fetchAffirmations();
if (Array.isArray(affirmations) && affirmations.length) {
const randomNumber = Math.floor(Math.random() * affirmations.length);
vscode.window.showInformationMessage(affirmations[randomNumber].text);
}
} catch {
// affirmation display is cosmetic -- don't block activation
}
The same defensive pattern should be applied inside each command handler (they also index into filtered arrays without a length check).
Location
extension.js:20-22Problem
If
fetchAffirmationsthrows (network error) or the API returns an error object instead of an array,affirmations.lengthisundefinedand.textthrows a TypeError. This crashes extension activation, which means none of the commands register.Suggested fix
The same defensive pattern should be applied inside each command handler (they also index into filtered arrays without a length check).