gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] 01/05: talerhttperror definition, for error in http


From: gnunet
Subject: [taler-wallet-core] 01/05: talerhttperror definition, for error in http request
Date: Thu, 19 Oct 2023 07:56:23 +0200

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

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

commit c6968c3c21d70bd76ce50f232650d183fa8cfa6e
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Thu Oct 19 02:43:36 2023 -0300

    talerhttperror definition, for error in http request
---
 packages/taler-util/src/errors.ts | 33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/packages/taler-util/src/errors.ts 
b/packages/taler-util/src/errors.ts
index dcdf56c39..f17f7db6a 100644
--- a/packages/taler-util/src/errors.ts
+++ b/packages/taler-util/src/errors.ts
@@ -34,19 +34,6 @@ import {
 
 type empty = Record<string, never>;
 
-export interface HttpErrors {
-  // timeout
-  [TalerErrorCode.WALLET_HTTP_REQUEST_GENERIC_TIMEOUT]: empty;
-  // throttled
-  [TalerErrorCode.WALLET_HTTP_REQUEST_THROTTLED]: empty;
-  // parsing
-  [TalerErrorCode.WALLET_RECEIVED_MALFORMED_RESPONSE]: empty;
-  // network
-  [TalerErrorCode.WALLET_NETWORK_ERROR]: empty;
-  // everything else
-  [TalerErrorCode.GENERIC_UNEXPECTED_REQUEST_ERROR]: empty;
-}
-
 export interface DetailsMap {
   [TalerErrorCode.WALLET_PENDING_OPERATION_FAILED]: {
     innerError: TalerErrorDetail;
@@ -102,7 +89,11 @@ export interface DetailsMap {
     requestMethod: string;
     throttleStats: Record<string, unknown>;
   };
-  [TalerErrorCode.WALLET_HTTP_REQUEST_GENERIC_TIMEOUT]: empty;
+  [TalerErrorCode.WALLET_HTTP_REQUEST_GENERIC_TIMEOUT]: {
+    requestUrl: string;
+    requestMethod: string;
+    timeoutMs: number;
+  };
   [TalerErrorCode.WALLET_NETWORK_ERROR]: {
     requestUrl: string;
     requestMethod: string;
@@ -205,6 +196,19 @@ export class TalerProtocolViolationError extends Error {
   }
 }
 
+// compute a subset of TalerError, just for http request
+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]>
+}
+
+export type TalerHttpError = TalerHttpErrorsDetails[keyof 
TalerHttpErrorsDetails]
+
 export class TalerError<T = any> extends Error {
   errorDetail: TalerErrorDetail & T;
   private constructor(d: TalerErrorDetail & T) {
@@ -239,6 +243,7 @@ export class TalerError<T = any> extends Error {
   ): this is TalerError<DetailsMap[C]> {
     return this.errorDetail.code === code;
   }
+
 }
 
 /**

-- 
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]