Skip to content

Vizel API / core/src / isVizelError

Function: isVizelError()

ts
function isVizelError(value): value is VizelError;

Defined in: packages/core/src/utils/errorHandling.ts:124

Type guard to check if a value is a VizelError.

Uses both instanceof check and structural check for robustness across multiple bundles or different realms.

Parameters

ParameterTypeDescription
valueunknownThe value to check

Returns

value is VizelError

True if the value is a VizelError

Example

typescript
try {
  await initEditor();
} catch (e) {
  if (isVizelError(e)) {
    handleVizelError(e);
  } else {
    throw e;
  }
}

Released under the MIT License.