Skip to content

Commit

Permalink
Log unhandled exceptions and highlight module loading oddity (#703)
Browse files Browse the repository at this point in the history
  • Loading branch information
lyonsil authored Jan 10, 2024
1 parent 6e4cec8 commit 5db4b9e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/renderer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import App from './app.component';
import { cleanupOldWebViewState } from './services/web-view-state.service';
import { blockWebSocketsToPapiNetwork } from './services/renderer-web-socket.service';

window.addEventListener('error', (errorEvent: ErrorEvent) => {
const { filename, lineno, colno, error } = errorEvent;
logger.error(`Unhandled error in renderer from ${filename}:${lineno}:${colno}, '${error}'`);
});

logger.info('Starting renderer');

// This is a little different than Promise.all in that the error message will have all the reasons
Expand Down
6 changes: 5 additions & 1 deletion src/shared/services/logger.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ if (isClient()) {
),
};
});
if (isExtensionHost())
else if (isExtensionHost())
// Add a tag for warnings so we can recognize them outside the process.
log.hooks.push((message) => {
const caller = identifyCaller();
Expand All @@ -136,6 +136,10 @@ if (isClient()) {
),
};
});
else {
// eslint-disable-next-line no-console
console.warn(chalk.yellow(`Unexpected process type: ${globalThis.processType}`));
}
} else {
log.initialize();
log.transports.console.level = globalThis.logLevel;
Expand Down

0 comments on commit 5db4b9e

Please sign in to comment.