Skip to content

Commit 90cdb3e

Browse files
author
jin
committed
-1
1 parent 55a2696 commit 90cdb3e

File tree

4 files changed

+14
-37
lines changed

4 files changed

+14
-37
lines changed

build/build.node.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ namespace $ {
956956
}
957957
}
958958
)
959-
if( errors.length ) $mol_fail_hidden( new AggregateError( errors, `Build fail ${path}` ) )
959+
if( errors.length ) $mol_fail_hidden( new $mol_error_mix( `Build fail ${path}`, ... errors ) )
960960

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

@@ -1011,7 +1011,7 @@ namespace $ {
10111011
this.logBundle( target , Date.now() - start )
10121012

10131013
if( errors.length ) {
1014-
const error = new AggregateError( errors, `Build fail ${path}` )
1014+
const error = new $mol_error_mix( `Build fail ${path}`, ... errors )
10151015
target.text( `console.error(${ JSON.stringify( error ) })` )
10161016
$mol_fail_hidden( error )
10171017
}
@@ -1067,7 +1067,7 @@ namespace $ {
10671067

10681068
this.logBundle( target , Date.now() - start )
10691069

1070-
if( errors.length ) $mol_fail_hidden( new AggregateError( errors, `Build fail ${path}` ) )
1070+
if( errors.length ) $mol_fail_hidden( new $mol_error_mix( `Build fail ${path}`, ... errors ) )
10711071

10721072
if( bundle === 'node' ) {
10731073
this.$.$mol_exec( this.root().path() , 'node' , '--trace-uncaught', target.relate( this.root() ) )

data/error/error.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
namespace $ {
22

3-
export class $mol_data_error extends AggregateError {
3+
export class $mol_data_error extends $mol_error_mix {
44
name = '$mol_data_error'
5-
constructor( message: string, errors = [] as Error[] ) {
6-
super( errors, [ message, ... errors.map( e => ' ' + e.message ) ].join( '\n' ) )
7-
}
85
}
96

107
}

data/variant/variant.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace $ {
3434

3535
}
3636

37-
return $mol_fail( new $mol_data_error( `${val} is not any of variants` , errors ) )
37+
return $mol_fail( new $mol_data_error( `${val} is not any of variants` , ... errors ) )
3838

3939
} , sub )
4040

error/mix/mix.ts

+9-29
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,15 @@
11
namespace $ {
22

3-
/** @deprecated Use AggregateError instead */
4-
export class $mol_error_mix extends Error {
5-
6-
errors : Error[]
7-
8-
constructor( message : string , ... errors : Error[] ) {
9-
10-
super( message )
11-
12-
this.errors = errors
13-
14-
if( errors.length ) {
15-
16-
const stacks = [ ... errors.map( error => error.stack ) , this.stack ]
17-
18-
const diff = $mol_diff_path( ... stacks.map( stack => {
19-
if( !stack ) return []
20-
return stack.split( '\n' ).reverse()
21-
} ) )
22-
23-
const head = diff.prefix.reverse().join( '\n' )
24-
const tails = diff.suffix.map( path => path.reverse().map( line => line.replace( /^(?!\s+at)/ , '\tat (.) ' ) ).join( '\n' ) ).join( '\n\tat (.) -----\n' )
25-
26-
this.stack = `Error: ${ this.constructor.name }\n\tat (.) /"""\\\n${ tails }\n\tat (.) \\___/\n${ head }`
27-
this.message += errors.map( error => '\n' + error.message ).join( '' )
28-
29-
}
30-
3+
export class $mol_error_mix extends AggregateError {
4+
5+
name = '$mol_data_error'
6+
constructor( message: string, ... errors: Error[] ) {
7+
super(
8+
errors,
9+
[ message, ... errors.map( e => ' ' + e.message ) ].join( '\n' ),
10+
)
3111
}
32-
12+
3313
toJSON() {
3414
return this.message
3515
}

0 commit comments

Comments
 (0)