This repository was archived by the owner on Jan 15, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 22
33import { Command as Base } from '@oclif/command'
44export { flags } from '@oclif/command'
5+ import { CLIError as OCLIFError } from '@oclif/errors'
56import { CLIError } from './clierror'
67export { CLIError } from './clierror'
78import ReadPipedData from './readpipeddata'
@@ -33,7 +34,7 @@ export abstract class Command extends Base {
3334 }
3435
3536 async catch ( err : any ) {
36- if ( err instanceof CLIError ) {
37+ if ( err instanceof CLIError || err instanceof OCLIFError ) {
3738 if ( ! err . message . match ( / E E X I T : 0 / ) ) {
3839 this . error ( err . message )
3940 }
@@ -71,7 +72,7 @@ export abstract class Command extends Base {
7172 }
7273
7374 private extractError ( input : string | Error ) : string {
74- return input instanceof Error ? input . message . concat ( input . name ) : input
75+ return input instanceof Error ? input . name : input
7576 }
7677
7778 private getTelemetryProperties ( ) : Array < string > {
Original file line number Diff line number Diff line change 11import { Command } from '../src/command'
22import { CLIError } from './../src/clierror'
3+ import { CLIError as OCLIFError } from '@oclif/errors'
34import { expect , fancy } from 'fancy-test'
45import ReadPipedStdin from '../src/readpipeddata'
56import * as path from 'path' ;
@@ -36,6 +37,20 @@ describe('command', () => {
3637 . do ( output => expect ( output . stderr ) . to . equal ( 'failure\n' ) )
3738 . it ( 'Exits with error' )
3839
40+ fancy
41+ . stderr ( )
42+ . do ( async ( ) => {
43+ class Test extends Command {
44+ async run ( ) {
45+ throw new OCLIFError ( 'failure' )
46+ }
47+ }
48+
49+ return Test . run ( [ ] )
50+ } )
51+ . do ( output => expect ( output . stderr ) . to . equal ( 'failure\n' ) )
52+ . it ( 'Handles OCLIF Errors' )
53+
3954 fancy
4055 . stderr ( )
4156 . do ( async ( ) => {
You can’t perform that action at this time.
0 commit comments