logging: guard HostProvider.get().logToChannel with try/catch; console fallback for early startup (IntelliJ plugin)

This commit is contained in:
kvyb
2025-09-23 07:58:44 +08:00
parent 84ec57b92d
commit f488ba3cbe
+7 -1
View File
@@ -32,7 +32,13 @@ export class Logger {
if (error?.message) {
fullMessage += ` ${error.message}`
}
HostProvider.get().logToChannel(`${level} ${fullMessage}`)
// During early startup, HostProvider may not be initialized yet.
// In that case, fall back to console logging instead of throwing.
try {
HostProvider.get().logToChannel(`${level} ${fullMessage}`)
} catch {
console.log(`${level} ${fullMessage}`)
}
if (error?.stack) {
console.log(`Stack trace:\n${error.stack}`)
}