Function createErrorMessage

  • Convert a stack of errors to a string.

    Parameters

    • src: string

      the source string you tried to parse

    • errorStack: DeadEnd<Ctx, Err>[]

      the stack of errors that occured when parsing the source string

    Returns undefined | string

    undefined if the stack of errors was empty, otherwise a string with the error message

    Example

    If we have the following invalid JSON:

    {
    "a": "b
    }

    We get the following error message:

    Cannot parse this value.
    
    2|      "a": "b
                   ^
    Expected a double quote: "