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

Function renderError

packages/cli/src/internal/prompt/multi-select.ts:49–69  ·  view source on GitHub ↗
(state: State, pointer: Doc.AnsiDoc)

Source from the content-addressed store, hash-verified

47}
48
49function renderError(state: State, pointer: Doc.AnsiDoc) {
50 return Option.match(state.error, {
51 onNone: () => Doc.empty,
52 onSome: (error) =>
53 Arr.match(error.split(NEWLINE_REGEX), {
54 onEmpty: () => Doc.empty,
55 onNonEmpty: (errorLines) => {
56 const annotateLine = (line: string): Doc.AnsiDoc =>
57 Doc.annotate(Doc.text(line), Ansi.combine(Ansi.italicized, Ansi.red))
58 const prefix = Doc.cat(Doc.annotate(pointer, Ansi.red), Doc.space)
59 const lines = Arr.map(errorLines, (str) => annotateLine(str))
60 return Doc.cursorSavePosition.pipe(
61 Doc.cat(Doc.hardLine),
62 Doc.cat(prefix),
63 Doc.cat(Doc.align(Doc.vsep(lines))),
64 Doc.cat(Doc.cursorRestorePosition)
65 )
66 }
67 })
68 })
69}
70
71function renderChoiceDescription<A>(
72 choice: Prompt.Prompt.SelectChoice<A>,

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