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

Function renderError

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

Source from the content-addressed store, hash-verified

50const NEWLINE_REGEX = /\r?\n/
51
52function renderError(state: State, pointer: Doc.AnsiDoc) {
53 return Option.match(state.error, {
54 onNone: () => Doc.empty,
55 onSome: (error) => {
56 const errorLines = error.split(NEWLINE_REGEX)
57 if (Arr.isNonEmptyReadonlyArray(errorLines)) {
58 const annotateLine = (line: string): Doc.AnsiDoc =>
59 Doc.annotate(Doc.text(line), Ansi.combine(Ansi.italicized, Ansi.red))
60 const prefix = Doc.cat(Doc.annotate(pointer, Ansi.red), Doc.space)
61 const lines = Arr.map(errorLines, (str) => annotateLine(str))
62 return Doc.cursorSavePosition.pipe(
63 Doc.cat(Doc.hardLine),
64 Doc.cat(prefix),
65 Doc.cat(Doc.align(Doc.vsep(lines))),
66 Doc.cat(Doc.cursorRestorePosition)
67 )
68 }
69 return Doc.empty
70 }
71 })
72}
73
74function renderParts(state: State, submitted: boolean = false) {
75 return Arr.reduce(

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…