MCPcopy
hub / github.com/vitejs/vite / prepareError

Function prepareError

packages/vite/src/node/server/middlewares/error.ts:11–23  ·  view source on GitHub ↗
(err: Error | RollupError)

Source from the content-addressed store, hash-verified

9import { CLIENT_PUBLIC_PATH } from '../../constants'
10
11export function prepareError(err: Error | RollupError): ErrorPayload['err'] {
12 // only copy the information we need and avoid serializing unnecessary
13 // properties, since some errors may attach full objects (e.g. PostCSS)
14 return {
15 message: strip(err.message),
16 stack: strip(cleanStack(err.stack || '')),
17 id: (err as RollupError).id,
18 frame: strip((err as RollupError).frame || ''),
19 plugin: (err as RollupError).plugin,
20 pluginCode: (err as RollupError).pluginCode?.toString(),
21 loc: (err as RollupError).loc,
22 }
23}
24
25export function buildErrorMessage(
26 err: RollupError,

Callers 5

listenMethod · 0.90
invalidateModuleMethod · 0.90
hmrFunction · 0.90
logErrorFunction · 0.85
errorMiddlewareFunction · 0.85

Calls 1

cleanStackFunction · 0.85

Tested by

no test coverage detected