⬅️ Back to Table of Contents
📄 serialize-error.ts
📊 Analysis Summary
Metric |
Count |
🔧 Functions |
1 |
📦 Imports |
2 |
📚 Table of Contents
🛠️ File Location:
📂 packages/ast-spec/tests/util/serialize-error.ts
📦 Imports
Name |
Source |
codeFrameColumns |
@babel/code-frame |
TSError |
./parsers/typescript-estree-import |
Functions
serializeError(error: unknown, contents: string): unknown
Code
export function serializeError(error: unknown, contents: string): unknown {
if (!(error instanceof TSError)) {
return error;
}
const {
location: { end, start },
message,
name,
} = error;
return `${name}
${codeFrameColumns(
contents,
{
end: { column: end.column + 1, line: end.line },
start: { column: start.column + 1, line: start.line },
},
{ highlightCode: false, message },
)}`;
}
- Parameters:
error: unknown
contents: string
- Return Type:
unknown
- Calls:
codeFrameColumns (from @babel/code-frame)