/** @packageDocumentation * @module IpcSocket */ import { LoggingMetaData } from "@itwin/core-bentley"; import { IpcInvokeReturn } from "./IpcSocket"; /** * Serialize a value thrown by an Ipc handler into the [[IpcInvokeReturn]] `error` envelope so it can be * transmitted across an Ipc socket via structured clone or JSON, depending on the transport. * * Hardens against values that can't be cloned: copies `Error`'s non-enumerable `message`/`stack`/`cause`, * preserves `BentleyError` identity (`iTwinErrorId` and logging metadata, normalized to a JSON-safe form), * recurses into nested `Error`s and plain objects, strips functions and class instances, and guards against cycles. * @param err The thrown value to serialize. * @param includeStack Whether to include `Error.stack` in the serialized output. * @returns An [[IpcInvokeReturn]] holding the serialized `error`. * @internal */ export declare function serializeIpcError(err: unknown, includeStack: boolean): IpcInvokeReturn; /** * Reconstruct an `Error` from the serialized `error` produced by [[serializeIpcError]], so the Ipc caller can * `throw` it. * * By default, rebuilds a plain `Error` following the `ITwinError` paradigm (identify via * [ITwinError.isError]($bentley), since `instanceof` cannot survive marshalling across the Ipc boundary). Pass * `typedErrorClass` for backwards compatibility to rebuild a legacy typed `BentleyError` subclass instead — the * frontend uses this to keep rethrowing [BackendError]($common). * @param err The serialized error object (must be an object; callers should forward non-object values as-is). * @param typedErrorClass Optional constructor for a legacy typed error (e.g. [BackendError]($common)). Omit for * the ITwinError paradigm. * @returns The reconstructed `Error` to throw. * @internal */ export declare function rebuildIpcError(err: any, typedErrorClass?: new (errorNumber: number, name: string, message: string, getMetaData?: LoggingMetaData) => Error): Error; //# sourceMappingURL=IpcErrors.d.ts.map