155
export function transformErrorForSerialization(error: any): any {
156
if (error instanceof Error) {
157
>
const { name, message, cause } = error;
errors.ts
158
>
// eslint-disable-next-line local/code-no-any-casts
159
>
const stack: string = (<any>error).stacktrace || (<any>error).stack;
160
>
return {
161
>
$isError: true,
162
>
name,
163
>
message,
164
>
stack,
165
>
noTelemetry: ErrorNoTelemetry.isErrorNoTelemetry(error),
166
>
cause: cause ? transformErrorForSerialization(cause) : undefined,
167
>
code: (<ErrorWithCode>error).code
168
>
};
169
>
}
170
171
// return as is