File tree 2 files changed +21
-1
lines changed
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ class BaseCommand extends Command {
35
35
async catch ( error ) {
36
36
const { flags } = await this . parse ( this . prototype )
37
37
aioLogger . error ( error ) // debug log
38
- this . error ( flags . verbose ? error . stack : error . message )
38
+ this . error ( flags . verbose && error . stack ? error . stack : error . message )
39
39
}
40
40
41
41
async init ( ) {
Original file line number Diff line number Diff line change @@ -302,6 +302,26 @@ test('will change error message when aio app outside of the application root (--
302
302
expect ( cmd . error ) . toHaveBeenCalledWith ( expect . stringContaining ( errorList . join ( '\n' ) ) )
303
303
} )
304
304
305
+ test ( 'will handle errors without stack traces when using --verbose flag' , async ( ) => {
306
+ const cmd = new TheCommand ( [ '--verbose' ] )
307
+ cmd . error = jest . fn ( )
308
+ const errorWithoutStack = new Error ( 'fake error' )
309
+ delete errorWithoutStack . stack
310
+ await cmd . catch ( errorWithoutStack )
311
+
312
+ expect ( cmd . error ) . toHaveBeenCalledWith ( expect . stringContaining ( 'fake error' ) )
313
+ } )
314
+
315
+ test ( 'will handle errors without stack traces when not using --verbose flag' , async ( ) => {
316
+ const cmd = new TheCommand ( [ ] )
317
+ cmd . error = jest . fn ( )
318
+ const errorWithoutStack = new Error ( 'fake error' )
319
+ delete errorWithoutStack . stack
320
+ await cmd . catch ( errorWithoutStack )
321
+
322
+ expect ( cmd . error ) . toHaveBeenCalledWith ( expect . stringContaining ( 'fake error' ) )
323
+ } )
324
+
305
325
test ( 'pjson' , async ( ) => {
306
326
const cmd = new TheCommand ( [ ] )
307
327
cmd . config = { pjson : { name : 'fake' , version : '0' } }
You can’t perform that action at this time.
0 commit comments