Skip to content

Commit 8f8cfe6

Browse files
author
jin
committed
Error print improve
1 parent e50749a commit 8f8cfe6

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

build/build.node.ts

+14-4
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,12 @@ namespace $ {
995995
}
996996
}
997997
)
998-
if( errors.length ) $mol_fail_hidden( new $mol_error_mix( `Build fail ${path}`, {}, ... errors ) )
998+
999+
if( errors.length ) {
1000+
const messages = errors.map( e => ' ' + e.message ).join( '\n' )
1001+
const error = new $mol_error_mix( `Build fail ${ pack.relate() }\n${ messages }`, {}, ... errors )
1002+
$mol_fail_hidden( error )
1003+
}
9991004

10001005
var targetJSMap = pack.resolve( `-/${bundle}.js.map` )
10011006

@@ -1050,8 +1055,9 @@ namespace $ {
10501055
this.logBundle( target , Date.now() - start )
10511056

10521057
if( errors.length ) {
1053-
const error = new $mol_error_mix( `Build fail ${path}`, {}, ... errors )
1054-
target.text( `console.error(${ JSON.stringify( error ) })` )
1058+
const messages = errors.map( e => ' ' + e.message ).join( '\n' )
1059+
const error = new $mol_error_mix( `Audit fail ${ pack.relate() }\n${ messages }`, {}, ... errors )
1060+
target.text( `console.error(${ JSON.stringify( error.stack ) })` )
10551061
$mol_fail_hidden( error )
10561062
}
10571063

@@ -1106,7 +1112,11 @@ namespace $ {
11061112

11071113
this.logBundle( target , Date.now() - start )
11081114

1109-
if( errors.length ) $mol_fail_hidden( new $mol_error_mix( `Build fail ${path}`, {}, ... errors ) )
1115+
if( errors.length ) {
1116+
const messages = errors.map( e => ' ' + e.message ).join( '\n' )
1117+
const error = new $mol_error_mix( `Build fail ${ pack.relate() }\n${ messages }`, {}, ... errors )
1118+
$mol_fail_hidden( error )
1119+
}
11101120

11111121
if( bundle === 'node' ) {
11121122
this.$.$mol_exec( this.root().path() , 'node' , '--enable-source-maps', '--trace-uncaught', target.relate( this.root() ) )

error/mix/mix.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace $ {
1515
const stack_get = Object.getOwnPropertyDescriptor( this, 'stack' )?.get ?? ( ()=> super.stack )
1616

1717
Object.defineProperty( this, 'stack', {
18-
get: ()=> stack_get.call( this ) + '\n' + [ JSON.stringify( this.cause, null, ' ' ) ?? 'no cause', ... this.errors.map( e => e.stack ) ].map(
18+
get: ()=> ( stack_get.call( this ) ?? this.message ) + '\n' + [ JSON.stringify( this.cause, null, ' ' ) ?? 'no cause', ... this.errors.map( e => e.stack ) ].map(
1919
e => e.trim()
2020
.replace( /at /gm, ' at ' )
2121
.replace( /^(?! +at )(.*)/gm, ' at | $1 (#)' )

0 commit comments

Comments
 (0)