Skip to content

Commit

Permalink
fix(sdk): dmmf error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
timsuchanek committed Jan 8, 2020
1 parent 06ea35f commit cc6780b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions cli/sdk/src/engineCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,17 @@ export async function getDMMF({
retry: retry - 1,
})
}
if (e.stderr) {
throw new Error(chalk.redBright.bold('Schema parsing\n') + e.stderr)
const output = e.stderr || e.stdout
if (output) {
let json
try {
json = JSON.parse(output)
} catch (e) {
//
}
const message = (json && json.message) || output

throw new Error(chalk.redBright.bold('Schema parsing\n') + message)
}
if (e.message.includes('in JSON at position')) {
throw new Error(
Expand Down

0 comments on commit cc6780b

Please sign in to comment.