Files
um-react/src/platform/errors.ts
T
鲁树人 b5fdc8ebbe feat: integrate platform provider with enhanced crypto handling and new AppLayout component
- Added a new `AppLayout` component to manage navigation and routing within the application.
- Refactored `AppRoot` to utilize `PlatformLoadGuard` for ensuring platform readiness before rendering.
- Introduced `useAppStore` hook for accessing the Redux store directly.
- Updated `SDKVersion` and `PanelQingTing` components to leverage the new platform provider for crypto operations.
- Enhanced error handling with `PlatformNotInitializedError` for better user feedback on uninitialized platform states.
- Added tests for new functionalities and ensured compatibility with the updated platform architecture.
2026-11-01 11:18:24 +09:00

49 lines
1.5 KiB
TypeScript

/**
* Thrown when a provider method is declared or expected but not wired yet.
* Distinct from {@link NotSupportedMethod} (platform does not support this call).
*/
export class NotImplementedError extends Error {
readonly code = 'NOT_IMPLEMENTED' as const;
constructor(
readonly capability: string,
message?: string,
) {
super(message ?? `Capability not implemented: ${capability}`);
this.name = 'NotImplementedError';
}
}
/**
* Thrown when `crypto.*` (or other init-gated APIs) is used before `provider.init()` completes.
* Distinct from {@link NotImplementedError} (not wired) and {@link NotSupportedMethod} (unsupported).
*/
export class PlatformNotInitializedError extends Error {
readonly code = 'NOT_INITIALIZED' as const;
constructor(
readonly capability: string,
message?: string,
) {
super(message ?? `Platform not initialized; call init() before using ${capability}`);
this.name = 'PlatformNotInitializedError';
}
}
/**
* Thrown when the current platform explicitly does not support a method / mode
* (e.g. Browser `keys.importNative`, or `saveMany(DirectWrite)` when not in `downloadTypes`).
* Callers should use `instanceof` / `code` — never treat as a silent no-op.
*/
export class NotSupportedMethod extends Error {
readonly code = 'NOT_SUPPORTED' as const;
constructor(
readonly capability: string,
message?: string,
) {
super(message ?? `Capability not supported: ${capability}`);
this.name = 'NotSupportedMethod';
}
}