diff options
author | Florian Dold <florian@dold.me> | 2023-12-04 21:16:39 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-12-04 21:16:39 +0100 |
commit | 8a3e6f25ef975e1a3177f73630f866a7b9b214fb (patch) | |
tree | f302eb6394447f8ee082d928b066f689fb3e980a /packages/taler-util/src/errors.ts | |
parent | 7f21700576b4de0f5479ea258b75fb141d18a41b (diff) | |
download | wallet-core-8a3e6f25ef975e1a3177f73630f866a7b9b214fb.tar.xz |
report content type if unexpected
Diffstat (limited to 'packages/taler-util/src/errors.ts')
-rw-r--r-- | packages/taler-util/src/errors.ts | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/packages/taler-util/src/errors.ts b/packages/taler-util/src/errors.ts index cbf4263fc..7439ba69d 100644 --- a/packages/taler-util/src/errors.ts +++ b/packages/taler-util/src/errors.ts @@ -103,6 +103,11 @@ export interface DetailsMap { requestMethod: string; httpStatusCode: number; validationError?: string; + /** + * Content type of the response, usually only specified if not the + * expected content type. + */ + contentType?: string; }; [TalerErrorCode.WALLET_EXCHANGE_COIN_SIGNATURE_INVALID]: empty; [TalerErrorCode.WALLET_WITHDRAWAL_GROUP_INCOMPLETE]: { @@ -197,17 +202,19 @@ export class TalerProtocolViolationError extends Error { } // compute a subset of TalerError, just for http request -type HttpErrors = TalerErrorCode.WALLET_HTTP_REQUEST_GENERIC_TIMEOUT +type HttpErrors = + | TalerErrorCode.WALLET_HTTP_REQUEST_GENERIC_TIMEOUT | TalerErrorCode.WALLET_HTTP_REQUEST_THROTTLED | TalerErrorCode.WALLET_RECEIVED_MALFORMED_RESPONSE | TalerErrorCode.WALLET_NETWORK_ERROR | TalerErrorCode.WALLET_UNEXPECTED_REQUEST_ERROR; type TalerHttpErrorsDetails = { - [code in HttpErrors]: TalerError<DetailsMap[code]> -} + [code in HttpErrors]: TalerError<DetailsMap[code]>; +}; -export type TalerHttpError = TalerHttpErrorsDetails[keyof TalerHttpErrorsDetails] +export type TalerHttpError = + TalerHttpErrorsDetails[keyof TalerHttpErrorsDetails]; export class TalerError<T = any> extends Error { errorDetail: TalerErrorDetail & T; @@ -243,7 +250,6 @@ export class TalerError<T = any> extends Error { ): this is TalerError<DetailsMap[C]> { return this.errorDetail.code === code; } - } /** |