1
0
mirror of https://github.com/tcgdex/cards-database.git synced 2025-04-23 03:12:10 +00:00

fix: better error logging for GraphQL

Signed-off-by: Florian BOUILLON <f.bouillon@aptatio.com>
This commit is contained in:
Florian Bouillon 2024-02-29 15:12:39 +01:00
parent f6e7871fc5
commit 0c29886812

View File

@ -19,9 +19,14 @@ function graphQLErrorHandle(error: GraphQLError) {
console.error(error)
}
if (error.source) {
const columns = (process?.stdout?.columns ?? 32) - 7
const dashes = ''.padEnd(columns / 2, '-')
console.error(`\x1b[91m${dashes} ERROR ${dashes}\x1b[0m`)
console.error('GraphQL Error')
console.error(error.message)
console.error(error.source?.body.replace(/\n/g, '\\n'))
console.error(error.source?.body)
console.error(`\x1b[91m${dashes} ERROR ${dashes}\x1b[0m`)
}
return formatError(error)
}