MCPcopy
hub / github.com/prisma/prisma / panicDialog

Function panicDialog

packages/internals/src/utils/handlePanic.ts:31–90  ·  view source on GitHub ↗
({
  error,
  cliVersion,
  enginesVersion,
  command,
  getDatabaseVersionSafe,
}: PanicDialog)

Source from the content-addressed store, hash-verified

29type PanicDialog = HandlePanic
30
31async function panicDialog({
32 error,
33 cliVersion,
34 enginesVersion,
35 command,
36 getDatabaseVersionSafe,
37}: PanicDialog): Promise<void> {
38 const errorMessage = error.message.split('\n').slice(0, Math.max(20, process.stdout.rows)).join('\n')
39
40 console.log(`${red('Oops, an unexpected error occurred!')}
41${red(errorMessage)}
42
43${bold('Please help us improve Prisma by submitting an error report.')}
44${bold('Error reports never contain personal or other sensitive information.')}
45${dim(`Learn more: ${link('https://pris.ly/d/telemetry')}`)}
46`)
47
48 const { value: shouldSubmitReport } = await prompt({
49 type: 'select',
50 name: 'value',
51 message: 'Submit error report',
52 initial: 0,
53 choices: [
54 {
55 title: 'Yes',
56 value: true,
57 description: `Send error report once`,
58 },
59 {
60 title: 'No',
61 value: false,
62 description: `Don't send error report`,
63 },
64 ],
65 })
66
67 if (shouldSubmitReport) {
68 try {
69 console.log('Submitting...')
70 const reportId = await sendPanic({ error, cliVersion, enginesVersion, getDatabaseVersionSafe })
71 console.log(`\n${bold(`We successfully received the error report id: ${reportId}`)}`)
72 console.log(`\n${bold('Thanks a lot for your help! 🙏')}`)
73 } catch (error) {
74 const reportFailedMessage = `${bold(red('Oops. We could not send the error report.'))}`
75 console.log(reportFailedMessage)
76 console.error(`${gray('Error report submission failed due to: ')}`, error)
77 }
78 }
79
80 await wouldYouLikeToCreateANewIssue({
81 prompt: !shouldSubmitReport,
82 error,
83 cliVersion,
84 enginesVersion,
85 command,
86 })
87
88 // Signal that there was an error

Callers 1

handlePanicFunction · 0.85

Calls 6

linkFunction · 0.90
sendPanicFunction · 0.90
logMethod · 0.80
errorMethod · 0.80
sliceMethod · 0.45

Tested by

no test coverage detected