UNPKG

brick-module

Version:

Better React Native native module development

29 lines 1.1 kB
//#region src/BrickError.d.ts /** * BrickError - Type-safe class for custom errors from native modules. * Matches the structure of iOS/Android BrickError. */ declare class BrickError extends Error { /** Error code (same as error.name) */ readonly code: string; /** Additional properties (e.g., amount, currency) */ readonly userInfo: Record<string, unknown>; /** Name of the module where the error occurred */ readonly moduleName?: string; constructor(message: string, code: string, userInfo?: Record<string, unknown>, moduleName?: string); /** * Type guard to check if an error object is a BrickError. * @param error - The error object to check * @returns true if the error is a BrickError */ static isBrickError(error: unknown): error is BrickError; /** * Converts a general error object to a BrickError. * @param error - The error object to convert * @param moduleName - Name of the module where the error occurred * @returns A BrickError instance */ static from(error: unknown, moduleName?: string): BrickError; } //#endregion export { BrickError };