Skip to content

Commit

Permalink
feat: print more info the error log, close #641
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Aug 11, 2021
1 parent d62e169 commit d648a01
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/utils/Log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,16 @@ export class Log {
}

static async error(err: Error | string | any = {}, prompt = true, intend = 0) {
if (typeof err !== 'string')
Log.info(`🐛 ERROR: ${err.name}: ${err.message}\n${err.stack}`, intend)
if (typeof err !== 'string') {
const messages = [
err.message,
err.response?.data,
err.stack,
err.toJSON?.(),
]
.filter(Boolean).join('\n')
Log.info(`🐛 ERROR: ${err.name}: ${messages}`, intend)
}

if (prompt) {
const openOutputButton = i18n.t('prompt.show_error_log')
Expand Down

0 comments on commit d648a01

Please sign in to comment.