UNPKG

react-native-onyx

Version:

State management for React Native

35 lines (34 loc) 1.88 kB
/** * Shared vocabulary for storage write failures. The *classes* are engine-agnostic; the *matching* * is not — each storage provider knows its own error dialect and owns its classifier (see each * provider's `classifyError`). This module deliberately holds NO string matchers: it is the common * taxonomy the two reacting layers agree on, while the per-engine knowledge lives with the engine. * * - the connection layer (`createStore`) recovers TRANSIENT and FATAL errors by reopening the DB, and * - the operation layer (`OnyxUtils.retryOperation`) recovers CAPACITY by eviction and retries UNKNOWN. * * This module has no Onyx dependencies (and no engine dependencies) so it can live in the storage * layer, and be imported by every provider, without creating an import cycle. */ declare const StorageErrorClass: { /** Connection/transport failure (stale connection). Owner: connection layer — reopen + retry once. */ readonly TRANSIENT: "transient"; /** Quota exceeded / disk full. Owner: operation layer — evict and retry. */ readonly CAPACITY: "capacity"; /** Non-serializable payload. Never retriable — the same data will always fail. */ readonly INVALID_DATA: "invalidData"; /** Backing-store corruption. Owner: connection layer — budgeted heal, then give up. */ readonly FATAL: "fatal"; /** Unmatched by the active provider. Owner: operation layer — bounded retry, and log the shape so * recurring cases can be promoted into one of the classes above. */ readonly UNKNOWN: "unknown"; }; /** * Normalizes any thrown value into a lowercased `{name, message}` pair for matching. Shared by every * provider's classifier so they all extract the error the same way. */ declare function getErrorParts(error: unknown): { name: string; message: string; }; export { StorageErrorClass, getErrorParts };