-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: show detailed error information in debug mode #1636
Changes from all commits
c28a89d
081b441
b4a574d
89edd2f
afd68d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
import { red, yellow } from 'chalk'; | ||
import debug from 'debug'; | ||
|
||
import env from '../../lib/env'; | ||
|
||
export function withError( message: Error | string ): never { | ||
console.error( `${ red( 'Error: ' ) } ${ message.toString().replace( /^Error:\s*/, '' ) }` ); | ||
const msg = message instanceof Error ? message.message : message; | ||
console.error( `${ red( 'Error: ' ) } ${ msg.replace( /^Error:\s*/, '' ) }` ); | ||
|
||
// Debug ouput is printed below error output both for information | ||
// hierarchy and to make it more likely that the user copies it to their | ||
// clipboard when dragging across output. | ||
console.log( | ||
`${ yellow( 'Debug: ' ) } VIP-CLI v${ env.app.version }, Node ${ env.node.version }, ${ | ||
env.os.name | ||
} ${ env.os.version }` | ||
} ${ env.os.version } ${ env.os.arch }` | ||
); | ||
|
||
if ( debug.names.length > 0 && message instanceof Error ) { | ||
console.error( yellow( 'Debug: ' ), message ); | ||
} | ||
|
||
process.exit( 1 ); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ export interface StepFromServer { | |
export class ProgressTracker { | ||
hasFailure: boolean; | ||
hasPrinted: boolean; | ||
printInterval: NodeJS.Timer | undefined; | ||
printInterval: NodeJS.Timeout | undefined; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a side-effect of installing |
||
|
||
// Track the state of each step | ||
stepsFromCaller: Map< string, Step >; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
export default class UserError extends Error { | ||
constructor( message: string ) { | ||
super( message ); | ||
constructor( message: string, options?: ErrorOptions ) { | ||
super( message, options ); | ||
Comment on lines
+2
to
+3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
this.name = 'UserError'; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": [ "es2021" ], | ||
"lib": [ "ES2022" ], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
"module": "node16", | ||
"strict": true, | ||
"esModuleInterop": true, | ||
|
@@ -9,7 +9,7 @@ | |
"moduleResolution": "node16", | ||
|
||
// Target latest version of ECMAScript. | ||
"target": "esnext", | ||
"target": "ES2022", | ||
// Don't parse types from JS as TS doesn't play well with Flow-ish JS. | ||
"allowJs": false, | ||
// Don't emit; allow Babel to transform files. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debug.enabled('*')
always returnstrue
:-(