diff options
author | Florian Dold <florian@dold.me> | 2024-06-17 13:05:16 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2024-06-17 13:05:16 +0200 |
commit | 05535fdc226f39666ed0a692871f54dea904af7b (patch) | |
tree | 6e9a4d6d376f576f4f1d271b6f6a691d501aeba2 /packages/taler-util/src | |
parent | b59e472465440d95525e7e3d1225234525948b67 (diff) | |
download | wallet-core-05535fdc226f39666ed0a692871f54dea904af7b.tar.xz |
wallet-core,harness: new test, provide reason for exchange entry update conflicts
Diffstat (limited to 'packages/taler-util/src')
-rw-r--r-- | packages/taler-util/src/errors.ts | 18 | ||||
-rw-r--r-- | packages/taler-util/src/taler-error-codes.ts | 8 | ||||
-rw-r--r-- | packages/taler-util/src/wallet-types.ts | 2 |
3 files changed, 28 insertions, 0 deletions
diff --git a/packages/taler-util/src/errors.ts b/packages/taler-util/src/errors.ts index d68177e4e..6becf7963 100644 --- a/packages/taler-util/src/errors.ts +++ b/packages/taler-util/src/errors.ts @@ -171,6 +171,9 @@ export interface DetailsMap { tosStatus: string; currentEtag: string | undefined; }; + [TalerErrorCode.WALLET_EXCHANGE_ENTRY_UPDATE_CONFLICT]: { + detail?: string; + }; } type ErrBody<Y> = Y extends keyof DetailsMap ? DetailsMap[Y] : empty; @@ -240,6 +243,21 @@ type TalerHttpErrorsDetails = { export type TalerHttpError = TalerHttpErrorsDetails[keyof TalerHttpErrorsDetails]; +/** + * Construct typed error details. + * Fills in the hint with a default based on the error code name. + */ +export function makeTalerErrorDetail<C extends TalerErrorCode>( + code: C, + errBody: ErrBody<C>, + hint?: string, +): TalerErrorDetail { + if (!hint) { + hint = getDefaultHint(code); + } + return { code, hint, ...errBody }; +} + export class TalerError<T = any> extends Error { errorDetail: TalerErrorDetail & T; cause: Error | undefined; diff --git a/packages/taler-util/src/taler-error-codes.ts b/packages/taler-util/src/taler-error-codes.ts index f77357407..a1b6ccc77 100644 --- a/packages/taler-util/src/taler-error-codes.ts +++ b/packages/taler-util/src/taler-error-codes.ts @@ -4137,6 +4137,14 @@ export enum TalerErrorCode { /** + * An exchange entry could not be updated, as the exchange's new details conflict with the new details. + * Returned with an HTTP status code of #MHD_HTTP_UNINITIALIZED (0). + * (A value of 0 indicates that the error is generated client-side). + */ + WALLET_EXCHANGE_ENTRY_UPDATE_CONFLICT = 7038, + + + /** * We encountered a timeout with our payment backend. * Returned with an HTTP status code of #MHD_HTTP_GATEWAY_TIMEOUT (504). * (A value of 0 indicates that the error is generated client-side). diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts index 82ccb4fc4..099e5c060 100644 --- a/packages/taler-util/src/wallet-types.ts +++ b/packages/taler-util/src/wallet-types.ts @@ -1391,6 +1391,8 @@ export interface ExchangeListItem { * to update the exchange info. */ lastUpdateErrorInfo?: OperationErrorInfo; + + unavailableReason?: TalerErrorDetail; } const codecForAuditorDenomSig = (): Codec<AuditorDenomSig> => |