Skip to content

ModelError

  • Error

new ModelError(message, level, cells?, type?, origException?): ModelError

string

Level = WARNING

ConvertibleToVertexIDs = null

indications of cell(s) or defined name(s) associated with the error

string = 'unknown'

error type identifier

original exception, included for troubleshooting errors whose reason is unknown

null | Error

ModelError

Error.constructor

optional cause: unknown

Error.cause


level: Level


message: string

Error.message


name: string

Error.name


origException: null | Error & object = null


optional stack: string

Error.stack


type: string


vertexIds: VertexIdSet<CellVertexId | NameVertexId>


workbook: null | Workbook = null


readonly static ERROR: 3


readonly static NONE: 0


readonly static NOTICE: 1


static 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.

Error.stackTraceLimit


readonly static UNKNOWN: -1


readonly static WARNING: 2

get references(): Set<string>

Set<string>

set of cell IDs (e.g. Sheet1!A1), defined names, and column names for structured sheets

toJSON(): object

Produce a representation of this error for JSON serialization. Adds the non-enumerable properties message and origException (the latter only if set), and makes cells an array. Despite the name, this does not return a JSON string, it returns an object to stringify instead of this one, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#tojson_behavior

object

an object that will JSON.stringify more usefully than this instance.

level: number

message: string

optional origException: object

message: string

stack: undefined | string

type: string

vertexIds: string[]


toString(): string

Returns a string representation of an object.

string


valueOf(): string

Returns the primitive value of the specified object.

string


static captureStackTrace(targetObject, constructorOpt?): void

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();

object

Function

void

Error.captureStackTrace


static fromCircularDependencyWith(vertexIds): ModelError

Create a circular dependency error involving the given cells.

ConvertibleToVertexIDs

vertex IDs of cells (defined names or sheet cells) known to be involved in a dependency cycle

ModelError


static fromInvalidCellValueAt(vertexIds): ModelError

Create an error about invalid cell values in workbook input in the given cells.

ConvertibleToVertexIDs

vertex IDs of cells (defined names or sheet cells) in which invalid cell values were found and replaced with #VALUE!

ModelError


static fromUnsupported(what, neverSupport, cell, isOrAre?, type?): ModelError

Create an error representing something unsupported (a spreadsheet function or other functionality) in a formula

string

the function name or a concise description of the functionality

boolean

true if we intend never to support the thing, false if we think we maybe will

the sheet-prefixed cell address or defined name whose formula contains the unsupported thing

CellVertexId | NameVertexId | CellItem

whichever verb form makes sense after what

"is" | "are"

optional override of the ModelError type; the default type is fn-unsup if neverSupport is true, else fn

null | string

ModelError


static isError(error): error is Error

Indicates whether the argument provided is a built-in Error instance or not.

unknown

error is Error

Error.isError


static prepareStackTrace(err, stackTraces): any

Error

CallSite[]

any

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Error.prepareStackTrace