MCPcopy Create free account
hub / github.com/Effect-TS/effect / renderError

Function renderError

packages/cli/src/internal/prompt/number.ts:68–88  ·  view source on GitHub ↗
(state: State, pointer: Doc.AnsiDoc)

Source from the content-addressed store, hash-verified

66const NEWLINE_REGEX = /\r?\n/
67
68function renderError(state: State, pointer: Doc.AnsiDoc) {
69 return Option.match(state.error, {
70 onNone: () => Doc.empty,
71 onSome: (error) =>
72 Arr.match(error.split(NEWLINE_REGEX), {
73 onEmpty: () => Doc.empty,
74 onNonEmpty: (errorLines) => {
75 const annotateLine = (line: string): Doc.AnsiDoc =>
76 Doc.annotate(Doc.text(line), Ansi.combine(Ansi.italicized, Ansi.red))
77 const prefix = Doc.cat(Doc.annotate(pointer, Ansi.red), Doc.space)
78 const lines = Arr.map(errorLines, (str) => annotateLine(str))
79 return Doc.cursorSavePosition.pipe(
80 Doc.cat(Doc.hardLine),
81 Doc.cat(prefix),
82 Doc.cat(Doc.align(Doc.vsep(lines))),
83 Doc.cat(Doc.cursorRestorePosition)
84 )
85 }
86 })
87 })
88}
89
90function renderOutput(
91 state: 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…