@@ -88,6 +88,7 @@ export class Ignite extends Macroable {
8888 shutdownLogs : true ,
8989 environments : [ ] ,
9090 exitOnError : true ,
91+ exitOnUncaughtError : false ,
9192 loadConfigSafe : true ,
9293 athennaRcPath : './.athennarc.json' ,
9394 uncaughtExceptionHandler : this . handleUncaughtError
@@ -529,24 +530,28 @@ export class Ignite extends Macroable {
529530 if ( process . versions . bun || ( ! Is . Error ( error ) && ! Is . Exception ( error ) ) ) {
530531 console . error ( error )
531532
532- return this . safeExit ( 1 )
533+ return this . safeExitOnError ( 1 )
533534 }
534535
535536 if ( ! Is . Exception ( error ) ) {
536537 error = error . toAthennaException ( )
537538 }
539+
540+ if ( ! error . details ) {
541+ error . details = [ ]
542+ }
538543
539544 error . details . push ( { isUncaughtError : false } )
540545
541546 if ( Config . is ( 'app.logger.prettifyException' , true ) ) {
542547 await Log . channelOrVanilla ( 'exception' ) . fatal ( await error . prettify ( ) )
543548
544- return this . safeExit ( 1 )
549+ return this . safeExitOnError ( 1 )
545550 }
546551
547552 await Log . channelOrVanilla ( 'exception' ) . fatal ( error )
548553
549- return this . safeExit ( 1 )
554+ return this . safeExitOnError ( 1 )
550555 }
551556
552557 /**
@@ -556,37 +561,52 @@ export class Ignite extends Macroable {
556561 if ( process . versions . bun || ( ! Is . Error ( error ) && ! Is . Exception ( error ) ) ) {
557562 console . error ( error )
558563
559- return this . safeExit ( 1 )
564+ return this . safeExitOnUncaughtError ( 1 )
560565 }
561566
562567 if ( ! Is . Exception ( error ) ) {
563568 error = error . toAthennaException ( )
564569 }
565570
571+ if ( ! error . details ) {
572+ error . details = [ ]
573+ }
574+
566575 error . details . push ( { isUncaughtError : true } )
567576
568577 if ( Config . is ( 'app.logger.prettifyException' , true ) ) {
569578 await Log . channelOrVanilla ( 'exception' ) . fatal ( await error . prettify ( ) )
570579
571- return this . safeExit ( 1 )
580+ return this . safeExitOnUncaughtError ( 1 )
572581 }
573582
574583 await Log . channelOrVanilla ( 'exception' ) . fatal ( error )
575584
576- return this . safeExit ( 1 )
585+ return this . safeExitOnUncaughtError ( 1 )
577586 }
578587
579588 /**
580589 * Exit the application only if the exitOnError option is true.
581590 */
582- private safeExit ( code : number ) : void {
591+ private safeExitOnError ( code : number ) : void {
583592 if ( ! this . options . exitOnError ) {
584593 return
585594 }
586595
587596 process . exit ( code )
588597 }
589598
599+ /**
600+ * Exit the application only if the exitOnUncaughtError option is true.
601+ */
602+ private safeExitOnUncaughtError ( code : number ) : void {
603+ if ( ! this . options . exitOnUncaughtError ) {
604+ return
605+ }
606+
607+ process . exit ( code )
608+ }
609+
590610 /**
591611 * Parse some version string to the SemverNode type.
592612 */
0 commit comments