-
Notifications
You must be signed in to change notification settings - Fork 389
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: show error stack on unknown error (#124)
* feat: show error stack on unknown error * improve message
- Loading branch information
1 parent
915a4ad
commit 5fe127d
Showing
8 changed files
with
45 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { dim } from 'kolorist'; | ||
import { version } from '../../package.json'; | ||
|
||
export class KnownError extends Error {} | ||
|
||
const indent = ' '; | ||
|
||
export const handleCliError = (error: any) => { | ||
if ( | ||
error instanceof Error | ||
&& !(error instanceof KnownError) | ||
) { | ||
if (error.stack) { | ||
console.error(dim(error.stack.split('\n').slice(1).join('\n'))); | ||
} | ||
console.error(`\n${indent}${dim(`aicommits v${version}`)}`); | ||
console.error(`\n${indent}Please open a Bug report with the information above:`); | ||
console.error(`${indent}https://github.com/Nutlope/aicommits/issues/new/choose`); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters