better debugging output

This commit is contained in:
Jake Bolam
2018-05-02 11:38:36 -04:00
parent fdee1bb1da
commit b1d7cc185c

View File

@@ -5,8 +5,16 @@ const stderr = console.error // eslint-disable-line no-console
const debug = error => {
if (process.env.DEBUG) {
const debugObject = error.response
? error.response.data
: error.response
stdout(chalk.greenBright(`[DEBUG] ${error.message}`))
stderr(error)
try {
stderr(JSON.stringify(debugObject, undefined, 2))
} catch (e) {
// eat it
}
}
}