export interface SFCCErrorLike { _v?: string; fault?: { arguments?: unknown; type?: string; message?: string; }; } export const isObject = (object: unknown): object is Record => { return typeof object === 'object' && object !== null && !Array.isArray(object); }; export const isSFCCError = (error: unknown): error is SFCCErrorLike => { console.log({ error }); if (!isObject(error)) return false; if (error instanceof Error) return true; return findError(error); }; function findError(error: T): boolean { if (Object.prototype.toString.call(error) === '[object Error]') { return true; } const prototype = Object.getPrototypeOf(error) as T | null; return prototype === null ? false : findError(prototype); }