Error for parsing/formatting issues.

Actionable shape: every parser-thrown ParsingError should carry as much locational context as is cheaply available — line, column, the offending cell value (truncated), and a human-readable hint that points at the most likely cause. The detailedMessage string built here is what users see in their console, in this layout:

: at line N, column M Context: Expected: / Actual: (if applicable) Value: "" (if applicable) Hint: (if applicable)

Hierarchy (View Summary)

Constructors

  • Parameters

    • message: string
    • lineNumber: number = null
    • column: number = null
    • context: string = null
    • expected: string = null
    • actual: string = null
    • meta: ErrorMeta & { value?: string; hint?: string } = {}

    Returns ParsingError

Properties

code: string
docs?: string
originalError?: Error
lineNumber: number
column: number
expected: string
actual: string
value: string

The exact cell value that triggered the error, truncated to 200 chars.

hint: string

Actionable next-step suggestion — usually a config flag or a fix pattern.

originalMessage: string
stackTraceLimit: number

The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)).

The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed.

If set to a non-number value, or set to a negative number, stack traces will not capture any frames.

cause?: unknown
name: string
message: string
stack?: string

Methods

  • Create a ParsingError for CSV format issues.

    Parameters

    • message: string
    • lineNumber: number = null
    • column: number = null
    • rowContent: string = null
    • Optionalhint: string

    Returns ParsingError

  • Create a ParsingError for field count mismatch. The most common cause: an unquoted comma inside a cell. The hint surfaces both the repairRowShifts opt-out and the quoting fix.

    Parameters

    • expectedCount: number
    • actualCount: number
    • lineNumber: number = null
    • rowContent: string = null

    Returns ParsingError

  • Create a ParsingError for unclosed quotes.

    Parameters

    • lineNumber: number = null
    • column: number = null
    • content: string = null

    Returns ParsingError

  • Create a ParsingError for invalid delimiter.

    Parameters

    • delimiter: string
    • lineNumber: number = null
    • context: string = null

    Returns ParsingError

  • Create a ParsingError for a cell value that the parser couldn't process (e.g. fast-path engine bailout). Surfaces both the offending value and a hint pointing at the most likely fallback config.

    Parameters

    • message: string
    • value: string
    • lineNumber: number = null
    • column: number = null
    • Optionalhint: string

    Returns ParsingError

  • Create a ParsingError for fast-path engine bailout.

    Parameters

    • reason: string
    • content: string = null

    Returns ParsingError

  • Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.

    const myObject = {};
    Error.captureStackTrace(myObject);
    myObject.stack; // Similar to `new Error().stack`

    The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}.

    The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace.

    The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance:

    function a() {
    b();
    }

    function b() {
    c();
    }

    function c() {
    // Create an error without stack trace to avoid calculating the stack trace twice.
    const { stackTraceLimit } = Error;
    Error.stackTraceLimit = 0;
    const error = new Error();
    Error.stackTraceLimit = stackTraceLimit;

    // Capture the stack trace above function b
    Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
    throw error;
    }

    a();

    Parameters

    • targetObject: object
    • OptionalconstructorOpt: Function

    Returns void