Skip to content

Commit 4e098d7

Browse files
refactor: improve exception handling in CLI entry points
- Add debug logging when import.meta is not available (CommonJS/Jest environment) - Only logs when DEBUG environment variable is set to avoid noise - Addresses SonarCloud code smells about empty catch blocks - Makes intentional error suppression more explicit - Helps with troubleshooting when needed
1 parent 787d7c2 commit 4e098d7

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/cloudevents/tools/generator/docs-generator/generate-docs-cli.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,9 @@ try {
146146
});
147147
}
148148
} catch (e) {
149-
// import.meta not available (CommonJS/Jest environment)
149+
// Intentionally ignoring error - import.meta not available (CommonJS/Jest environment)
150+
// This is expected when the module is imported rather than executed directly
151+
if (process.env.DEBUG) {
152+
console.debug('Module loaded in CommonJS/Jest environment (import.meta not available)');
153+
}
150154
}

src/cloudevents/tools/generator/readme-generator/update-readme-cli.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,9 @@ try {
8080
});
8181
}
8282
} catch (e) {
83-
// import.meta not available (CommonJS/Jest environment)
83+
// Intentionally ignoring error - import.meta not available (CommonJS/Jest environment)
84+
// This is expected when the module is imported rather than executed directly
85+
if (process.env.DEBUG) {
86+
console.debug("Module loaded in CommonJS/Jest environment (import.meta not available)");
87+
}
8488
}

0 commit comments

Comments
 (0)