diff options
author | Sebastian <sebasjm@gmail.com> | 2023-06-28 11:38:01 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-06-28 11:38:01 -0300 |
commit | 28dce57f92d5f1fc276098e262aa37139c614e26 (patch) | |
tree | 95630884ef03897e1040abde5aa14a8387f27e1d /packages/taler-wallet-webextension/src/wxApi.ts | |
parent | ce3c3d78392c25300d0a96e140c6092a6b8a898d (diff) | |
download | wallet-core-28dce57f92d5f1fc276098e262aa37139c614e26.tar.xz |
fix: 7740 check max on p2p push
Diffstat (limited to 'packages/taler-wallet-webextension/src/wxApi.ts')
-rw-r--r-- | packages/taler-wallet-webextension/src/wxApi.ts | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/packages/taler-wallet-webextension/src/wxApi.ts b/packages/taler-wallet-webextension/src/wxApi.ts index ce1dac14f..46c9f1b2d 100644 --- a/packages/taler-wallet-webextension/src/wxApi.ts +++ b/packages/taler-wallet-webextension/src/wxApi.ts @@ -24,9 +24,11 @@ import { AbsoluteTime, CoreApiResponse, + DetailsMap, Logger, LogLevel, NotificationType, + TalerError, TalerErrorCode, TalerErrorDetail, WalletDiagnostics, @@ -92,13 +94,19 @@ export interface BackgroundApiClient { ): Promise<BackgroundOperations[Op]["response"]>; } -export class BackgroundError extends Error { - public errorDetail: TalerErrorDetail; +export class BackgroundError<T = any> extends Error { + public errorDetail: TalerErrorDetail & T; - constructor(title: string, e: TalerErrorDetail) { + constructor(title: string, e: TalerErrorDetail & T) { super(title); this.errorDetail = e; } + + hasErrorCode<C extends keyof DetailsMap>( + code: C, + ): this is BackgroundError<DetailsMap[C]> { + return this.errorDetail.code === code; + } } /** |