MCPcopy Create free account
hub / github.com/chakra-ui/panda / handleError

Function handleError

packages/cli/src/errors.ts:5–31  ·  view source on GitHub ↗
(error: unknown)

Source from the content-addressed store, hash-verified

3import { PandaError } from '@pandacss/shared'
4
5export function handleError(error: unknown) {
6 if (error instanceof PandaError) {
7 console.error(colors.red(`${error.code}: ${error.message}`))
8 if (error.hint) {
9 console.error(colors.dim(error.hint))
10 }
11 if (error.cause instanceof Error) {
12 console.error(colors.dim(`Caused by: ${error.cause.message}`))
13 }
14 } else if (isLocError(error)) {
15 console.error(colors.bold(colors.red(`Error parsing: ${error.loc.file}:${error.loc.line}:${error.loc.column}`)))
16 if (error.frame) {
17 console.error(colors.red(error.message))
18 console.error(colors.dim(error.frame))
19 } else {
20 console.error(colors.red(error.message))
21 }
22 } else {
23 const message = error instanceof Error ? error.message : String(error)
24 console.error(colors.red(message))
25 }
26
27 process.exitCode = 1
28 if (!isMainThread && parentPort) {
29 parentPort.postMessage('error')
30 }
31}
32
33interface LocError {
34 loc: { file: string; line: number; column: number }

Callers

nothing calls this directly

Calls 1

isLocErrorFunction · 0.85

Tested by

no test coverage detected