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

Function renderTextError

packages/effect/src/unstable/cli/Prompt.ts:3533–3552  ·  view source on GitHub ↗
(
  nextState: TextState,
  pointer: string,
  renderOptions?: RenderOptions | undefined
)

Source from the content-addressed store, hash-verified

3531}
3532
3533const renderTextError = (
3534 nextState: TextState,
3535 pointer: string,
3536 renderOptions?: RenderOptions | undefined
3537): string => {
3538 if (Option.isSome(nextState.error)) {
3539 return Arr.match(nextState.error.value.split(NEWLINE_REGEXP), {
3540 onEmpty: () => "",
3541 onNonEmpty: (errorLines) => {
3542 if (renderOptions?.plain === true) {
3543 return `${pointer} ${errorLines.join("\n")}`
3544 }
3545 const prefix = Ansi.annotate(pointer, Ansi.red) + " "
3546 const lines = Arr.map(errorLines, (str) => annotateErrorLine(str))
3547 return Ansi.cursorSavePosition + "\n" + prefix + lines.join("\n") + Ansi.cursorRestorePosition
3548 }
3549 })
3550 }
3551 return ""
3552}
3553
3554const renderTextOutput = (
3555 nextState: TextState,

Callers 1

Prompt.tsFile · 0.85

Calls 5

annotateErrorLineFunction · 0.85
joinMethod · 0.80
annotateMethod · 0.65
splitMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected