Skip to content

Commit

Permalink
feat - global error handler
Browse files Browse the repository at this point in the history
  • Loading branch information
jaga-live committed Jan 13, 2024
1 parent 63a47cb commit c925479
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/core/app/exception.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const globalErrorHandler = (error: Error) => {
console.error(
`\x1b[31m[ ${new Date()} ] Unhandled Exception: ${error.stack}\x1b[0m\n`,
);
};

process.on('uncaughtException', globalErrorHandler);
process.on('unhandledRejection', globalErrorHandler);
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { App } from './app';
import container from './core/inversify/inversify.di';
import { DI_TYPES } from './core/inversify/types.di';
import './core/app/exception';

async function bootstrap() {
const _app = container.get<App>(DI_TYPES.App);
Expand Down

0 comments on commit c925479

Please sign in to comment.