File tree Expand file tree Collapse file tree 5 files changed +10
-37
lines changed Expand file tree Collapse file tree 5 files changed +10
-37
lines changed Original file line number Diff line number Diff line change 1
- import * as lodash from 'lodash' ;
2
1
import * as util from 'util' ;
3
2
4
3
import { ValidationError } from './definitions' ;
@@ -10,25 +9,11 @@ export const ERROR_IPC_UNKNOWN_PROCEDURE = 'ERR_ICF_IPC_UNKNOWN_PROCEDURE';
10
9
11
10
export abstract class BaseError extends Error {
12
11
abstract readonly name : string ;
13
- message : string ;
14
- stack : string ;
15
12
code ?: string ;
16
- error ?: Error ;
17
13
exitCode ?: number ;
18
14
19
- constructor ( message : string ) {
20
- super ( message ) ;
21
- this . message = message ;
22
- this . stack = ( new Error ( ) ) . stack || '' ;
23
- }
24
-
25
15
toString ( ) : string {
26
- const repr = lodash . pick ( this , lodash . pull ( lodash . keys ( this ) , 'error' ) ) ;
27
-
28
- return (
29
- `${ this . name } : ${ this . message } ${ util . inspect ( repr , { breakLength : Infinity } ) } ${ this . stack } ` +
30
- `${ this . error ? `\nWrapped: ${ this . error . stack ? this . error . stack : this . error } ` : '' } `
31
- ) ;
16
+ return util . inspect ( this ) ;
32
17
}
33
18
34
19
inspect ( ) : string {
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { readPackageJsonFile } from '@ionic/cli-framework/utils/node';
3
3
import { processExit } from '@ionic/utils-process' ;
4
4
import * as Debug from 'debug' ;
5
5
import * as path from 'path' ;
6
+ import * as util from 'util' ;
6
7
7
8
import { IonicNamespace } from './commands' ;
8
9
import { IPCMessage , IonicContext , IonicEnvironment } from './definitions' ;
@@ -171,11 +172,7 @@ export async function run(pargv: string[]): Promise<void> {
171
172
} else if ( err instanceof BaseError ) {
172
173
ienv . log . error ( err . message ) ;
173
174
} else {
174
- ienv . log . msg ( failure ( String ( err . stack ? err . stack : err ) ) ) ;
175
-
176
- if ( err . stack ) {
177
- debug ( failure ( String ( err . stack ) ) ) ;
178
- }
175
+ ienv . log . rawmsg ( failure ( util . inspect ( err ) ) ) ;
179
176
}
180
177
}
181
178
}
Original file line number Diff line number Diff line change @@ -55,9 +55,9 @@ export class ProjectDetailsError extends BaseException {
55
55
/**
56
56
* The underlying error that caused this error.
57
57
*/
58
- readonly error ?: Error
58
+ cause ?: Error
59
59
) {
60
- super ( msg ) ;
60
+ super ( msg , { cause } ) ;
61
61
}
62
62
}
63
63
@@ -193,7 +193,7 @@ export class ProjectDetails {
193
193
if ( e1 ) {
194
194
log . error (
195
195
`Error while loading config (project config: ${ strong ( prettyPath ( result . configPath ) ) } )\n` +
196
- `${ e1 . error ? `${ e1 . message } : ${ failure ( e1 . error . toString ( ) ) } ` : failure ( e1 . message ) } . ` +
196
+ `${ e1 . cause ? `${ e1 . message } : ${ failure ( e1 . cause . toString ( ) ) } ` : failure ( e1 . message ) } . ` +
197
197
`Run ${ input ( 'ionic init' ) } to re-initialize your Ionic project. Without a valid project config, the CLI will not have project context.`
198
198
) ;
199
199
Original file line number Diff line number Diff line change @@ -35,20 +35,11 @@ export function convertPATH(path = process.env.PATH || ''): string {
35
35
36
36
export class SubprocessError extends Error {
37
37
readonly name = 'SubprocessError' ;
38
- message : string ;
39
- stack : string ;
40
38
41
39
code ?: typeof ERROR_COMMAND_NOT_FOUND | typeof ERROR_NON_ZERO_EXIT | typeof ERROR_SIGNAL_EXIT ;
42
- error ?: Error ;
43
40
output ?: string ;
44
41
signal ?: string ;
45
42
exitCode ?: number ;
46
-
47
- constructor ( message : string ) {
48
- super ( message ) ;
49
- this . message = message ;
50
- this . stack = ( new Error ( ) ) . stack || '' ;
51
- }
52
43
}
53
44
54
45
export interface SubprocessOptions extends SpawnOptions { }
@@ -172,13 +163,12 @@ export class Subprocess {
172
163
let err : SubprocessError ;
173
164
174
165
if ( error . code === 'ENOENT' ) {
175
- err = new SubprocessError ( 'Command not found.' ) ;
166
+ err = new SubprocessError ( 'Command not found.' , { cause : error } ) ;
176
167
err . code = ERROR_COMMAND_NOT_FOUND ;
177
168
} else {
178
- err = new SubprocessError ( 'Command error.' ) ;
169
+ err = new SubprocessError ( 'Command error.' , { cause : error } ) ;
179
170
}
180
171
181
- err . error = error ;
182
172
reject ( err ) ;
183
173
} ) ;
184
174
Original file line number Diff line number Diff line change 12
12
"target" : " ES2021" ,
13
13
"types" : [],
14
14
"lib" : [
15
- " ES2021"
15
+ " ES2021" ,
16
+ " ES2022.Error"
16
17
]
17
18
}
18
19
}
You can’t perform that action at this time.
0 commit comments