chore: clean-up critical error handling
This commit is contained in:
parent
c76ec91d15
commit
1a5cad40a2
1 changed files with 8 additions and 10 deletions
18
src/index.ts
18
src/index.ts
|
|
@ -17,16 +17,6 @@ if (envIsProd()) {
|
|||
console.log = console.warn = console.error = console.info = console.debug = () => { /* disable in favor of logger */ };
|
||||
}
|
||||
|
||||
// At your app’s entry point
|
||||
process.on('uncaughtException', (err) => {
|
||||
console.error('Uncaught exception caught:', err);
|
||||
// Decide: exit gracefully or continue
|
||||
});
|
||||
|
||||
process.on('unhandledRejection', (reason) => {
|
||||
console.error('Unhandled rejection:', reason);
|
||||
});
|
||||
|
||||
const logger = winston.createLogger({
|
||||
transports: [
|
||||
new winston.transports.Console({
|
||||
|
|
@ -38,6 +28,14 @@ const logger = winston.createLogger({
|
|||
],
|
||||
});
|
||||
|
||||
process.on('uncaughtException', (error) => {
|
||||
logger.error('Uncaught exception caught:', error);
|
||||
});
|
||||
|
||||
process.on('unhandledRejection', (reason) => {
|
||||
logger.error('Unhandled rejection: ', reason);
|
||||
});
|
||||
|
||||
if (process.env['ALL_PROXY']) {
|
||||
const proxyUrl = new URL(process.env['ALL_PROXY']);
|
||||
if (proxyUrl.protocol === 'socks5:') {
|
||||
|
|
|
|||
Loading…
Reference in a new issue