MCPcopy Index your code
hub / github.com/Effect-TS/effect / renderError

Function renderError

packages/cli/src/internal/prompt/text.ts:97–119  ·  view source on GitHub ↗
(nextState: State, pointer: Doc.AnsiDoc)

Source from the content-addressed store, hash-verified

95}
96
97function renderError(nextState: State, pointer: Doc.AnsiDoc) {
98 return Option.match(nextState.error, {
99 onNone: () => Doc.empty,
100 onSome: (error) =>
101 Arr.match(error.split(/\r?\n/), {
102 onEmpty: () => Doc.empty,
103 onNonEmpty: (errorLines) => {
104 const annotateLine = (line: string): Doc.AnsiDoc =>
105 Doc.text(line).pipe(
106 Doc.annotate(Ansi.combine(Ansi.italicized, Ansi.red))
107 )
108 const prefix = Doc.cat(Doc.annotate(pointer, Ansi.red), Doc.space)
109 const lines = Arr.map(errorLines, (str) => annotateLine(str))
110 return Doc.cursorSavePosition.pipe(
111 Doc.cat(Doc.hardLine),
112 Doc.cat(prefix),
113 Doc.cat(Doc.align(Doc.vsep(lines))),
114 Doc.cat(Doc.cursorRestorePosition)
115 )
116 }
117 })
118 })
119}
120
121function renderOutput(
122 nextState: State,

Callers 1

renderNextFrameFunction · 0.70

Calls 5

splitMethod · 0.80
annotateLineFunction · 0.70
annotateMethod · 0.65
mapMethod · 0.65
pipeMethod · 0.65

Tested by

no test coverage detected