API

Function decodeError

  • Decode a Babylon-Lite error into its full, human-readable message.

    Accepts unknown so you can hand it a catch binding directly (which TypeScript types as unknown) with no cast. Works even when enableErrorDecoding was never called: by default Babylon-Lite throws errors whose message is the bare code #<code> with the interpolation args attached as a lite property, so this reads the code and args back out and runs them through the message table. If the error was already decoded (decoding was enabled when it was thrown) or isn't a Babylon-Lite coded error, its message is returned unchanged (non-Error values are stringified).

    Importing this module pulls in the message table chunk (same as enableErrorDecoding), so avoid statically importing it into lean production bundles; the intended production pattern is to import() it lazily from a catch/telemetry path only when an error actually fires.

    Parameters

    • error: unknown

    Returns string