Search Docs
Loading...
Skip to content

Class: EngineError

Structured CE.SDK error. Extends the standard JS Error so existing try { ... } catch (error) { console.log(error.message); } flows keep working — message is the engine’s rendered English string. The structured fields (code, category, hint, args, docsUrl, silent) let consumers branch on stable identifiers instead of matching on the message string and surface customer-facing copy + doc links.

Every engine error carries a stable, non-empty catalog code. Branch on the codes you handle and keep a default fallback to the message for the rest — the catalog is append-only, so existing codes never change meaning but new codes ship over time.

The error’s name embeds the code ("EngineError [SCENE.NOT_VALID]"), so stack traces and String(error) identify the failure without inspecting fields. Don’t match on name — narrow with isEngineError (or instanceof) and branch on code.

When logging to an external service, note that JSON.stringify(error) serializes the structured own fields but — as with any Error — omits message and stack. Extract the payload explicitly, e.g. { code: error.code, message: error.message, hint: error.hint, args: error.args }.

Example#

try {
engine.block.setTextFontSize(blockId, 0);
} catch (error) {
if (error instanceof EngineError && error.code === 'BLOCK.TEXT_INVALID_FONT_SIZE') {
toast.show(t(`error.${camelCase(error.code)}`, error.args));
if (error.docsUrl) window.open(error.docsUrl);
} else {
throw error;
}
}

Extends#

  • Error

Constructors#

Constructor#


| Parameter | Type | | ------ | ------ | | message? | string |

Returns#

EngineError

Inherited from#

Error.constructor

Constructor#


| Parameter | Type | | ------ | ------ | | message? | string | | options? | ErrorOptions |

Returns#

EngineError

Inherited from#

Error.constructor

Methods#

captureStackTrace()#


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#

ParameterType
targetObjectobject
constructorOpt?Function

Returns#

void

Inherited from#

Error.captureStackTrace

Signature#

captureStackTrace(targetObject: object, constructorOpt?: Function): void

prepareStackTrace()#


| Parameter | Type | | ------ | ------ | | err | Error | | stackTraces | CallSite[] |

Returns#

any

See#

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

Inherited from#

Error.prepareStackTrace

Signature#

prepareStackTrace(err: Error, stackTraces: CallSite[]): any

Properties#

PropertyModifierTypeDescriptionInherited from
stackTraceLimitstaticnumberThe 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
codereadonlystringStable catalog id (e.g. "SCENE.NOT_VALID"). Non-empty for every engine error.-
categoryreadonlystringCategory prefix of code (e.g. "SCENE").-
hintreadonlystringEnglish “what to do next” hint, already interpolated with args. Empty when the catalog entry does not declare a hint.-
argsreadonlyRecord<string, EngineErrorArg>Typed template arguments. Numbers stay numbers, booleans stay booleans, strings stay strings — pass this map straight into i18next/Intl.NumberFormat/etc.-
silentreadonlybooleanWhether the catalog marks this error as silent (expected platform limitation that should not be logged). Consumers may still surface it programmatically.-
docsUrlreadonlystringFully-qualified docs URL on img.ly, e.g. https://img.ly/docs/cesdk/js/user-interface/font-size-d194d1/. null when the catalog entry links no docs page.-
cause?publicunknown-Error.cause
namepublicstring-Error.name
messagepublicstring-Error.message
stack?publicstring-Error.stack