gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated: report content type if unexpe


From: gnunet
Subject: [taler-wallet-core] branch master updated: report content type if unexpected
Date: Mon, 04 Dec 2023 21:16:35 +0100

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository wallet-core.

The following commit(s) were added to refs/heads/master by this push:
     new 8a3e6f25e report content type if unexpected
8a3e6f25e is described below

commit 8a3e6f25ef975e1a3177f73630f866a7b9b214fb
Author: Florian Dold <florian@dold.me>
AuthorDate: Mon Dec 4 21:16:39 2023 +0100

    report content type if unexpected
---
 packages/taler-util/src/errors.ts      | 16 +++++++++++-----
 packages/taler-util/src/http-common.ts |  1 +
 2 files changed, 12 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;
   }
-
 }
 
 /**
diff --git a/packages/taler-util/src/http-common.ts 
b/packages/taler-util/src/http-common.ts
index e934c07f7..7c58b3874 100644
--- a/packages/taler-util/src/http-common.ts
+++ b/packages/taler-util/src/http-common.ts
@@ -155,6 +155,7 @@ export async function readTalerErrorResponse(
         requestUrl: httpResponse.requestUrl,
         requestMethod: httpResponse.requestMethod,
         httpStatusCode: httpResponse.status,
+        contentType: contentType || "<null>",
       },
       "Error response did not even contain JSON. The request URL might be 
wrong or the service might be unavailable.",
     );

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]