# All files / src/utils generate-error.js

100% Statements 6/6
100% Branches 0/0
100% Functions 1/1
100% Lines 6/6

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33

    19x
    19x
    19x
    19x

    19x

    19x

     // @flow

    export default function generateErrorString(
      msg: string,
      error: string,
      marker: {
        start: { sourceLine: string, line: number, col: number },
        end: { sourceLine: string, line: number, col: number },
      },
      filename: string,
      func: string
    ): string {
      const line = marker.start.line;
      const col = marker.start.col;
      const end = marker.end.col;
      const Line = marker.end.sourceLine;

      const highlight = new Array(end - col + 2)
        .join('^')
        .padStart(marker.start.col - 2, ' ');
      return (
        '\n' +
        Line +
        '\n' +
        highlight +
        ` ${error}` +
        '\n' +
        msg +
        '\n' +
        `  at ${func} (${filename}:${line}:${col})`
      );
    }