[**CameraKit Web SDK v1.23.1**](../README.md)

***

[CameraKit Web SDK](../globals.md) / LensScriptError

# Type Alias: LensScriptError

> **LensScriptError**: `NamedError`\<`"LensScriptError"`\>

The error a Lens script threw, for example a `TypeError` in one of its `.js` files.

Camera Kit never surfaces this error directly. It is the `cause` at the end of the chain behind the error you
actually receive, and which one you receive depends on when the script failed:

- **Before `applyLens` resolved.** The script threw while starting up, typically in `onAwake` or top-level code.
  `applyLens` rejects with a [LensError](LensError.md) and the Lens is not applied.
- **After `applyLens` resolved.** The script threw while the Lens was running, typically in an event handler such
  as an update, tap, or delayed callback. Camera Kit removes the Lens and emits a [LensExecutionError](LensExecutionError.md) on
  the session's `error` event.

Use [findLensScriptError](../functions/findLensScriptError.md) to retrieve it from either.

- `message` is the script's error, e.g. `TypeError: cannot read property 'text' of undefined`.
- `stack` lists the Lens script frames, one per line, in the same `at function (file:line:column)` shape browsers
  use, so it renders in DevTools and error reporters. File names refer to the scripts inside the Lens project, so
  they are most useful to the Lens creator.

**Note:** No `LensScriptError` is created at all if the script `throw`s something other than an `Error` (a
string, a number, a plain object). JavaScript only captures a stack when an `Error` is constructed, so a script
that throws a bare value produces no frames — even though the script is what caused the failure.
