Skip to content

Commit

Permalink
chore: add error interface (#375)
Browse files Browse the repository at this point in the history
  • Loading branch information
y-lakhdar committed Sep 27, 2022
1 parent 6e6d5bc commit eac6b32
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export default abstract class Command {
return Parser.parse(argv, opts)
}

protected async catch(err: Error & {exitCode?: number}): Promise<any> {
protected async catch(err: Interfaces.CommandError): Promise<any> {
process.exitCode = process.exitCode ?? err.exitCode ?? 1
if (this.jsonEnabled()) {
CliUx.ux.styledJSON(this.toErrorJson(err))
Expand Down
2 changes: 2 additions & 0 deletions src/interfaces/errors.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export type CommandError = Error & {exitCode?: number};

export interface OclifError {
oclif: {
exit?: number | false;
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export {AlphabetLowercase, AlphabetUppercase} from './alphabet'
export {Config, ArchTypes, PlatformTypes, LoadOptions} from './config'
export {Command, Example} from './command'
export {OclifError, PrettyPrintableError} from './errors'
export {OclifError, PrettyPrintableError, CommandError} from './errors'
export {HelpOptions} from './help'
export {Hook, Hooks} from './hooks'
export {Manifest} from './manifest'
Expand Down

0 comments on commit eac6b32

Please sign in to comment.