diff options
| author | Sebastian <sebasjm@gmail.com> | 2023-01-17 15:58:20 -0300 | 
|---|---|---|
| committer | Sebastian <sebasjm@gmail.com> | 2023-01-17 16:01:26 -0300 | 
| commit | eeea3e62a01638b37c8bb8d6f8fdeac129a4afae (patch) | |
| tree | fd1e97f0c3dda5b4077e7e0b53d8c844a8fc9aa4 /packages/taler-wallet-core/src/util | |
| parent | 5be2d128ed088a77d6448ac1ebf25aba3716bd81 (diff) | |
stronger type check to be sure that ErrorDetails is consistent
Diffstat (limited to 'packages/taler-wallet-core/src/util')
| -rw-r--r-- | packages/taler-wallet-core/src/util/http.ts | 14 | 
1 files changed, 12 insertions, 2 deletions
| diff --git a/packages/taler-wallet-core/src/util/http.ts b/packages/taler-wallet-core/src/util/http.ts index 118da40fe..1da31a315 100644 --- a/packages/taler-wallet-core/src/util/http.ts +++ b/packages/taler-wallet-core/src/util/http.ts @@ -68,7 +68,7 @@ export interface HttpRequestOptions {     */    cancellationToken?: CancellationToken; -  body?: string | ArrayBuffer | Object; +  body?: string | ArrayBuffer | Record<string, unknown>;  }  /** @@ -185,6 +185,7 @@ export async function readUnexpectedResponseDetails(      TalerErrorCode.WALLET_UNEXPECTED_REQUEST_ERROR,      {        requestUrl: httpResponse.requestUrl, +      requestMethod: httpResponse.requestMethod,        httpStatusCode: httpResponse.status,        errorResponse: errJson,      }, @@ -211,6 +212,7 @@ export async function readSuccessResponseJsonOrErrorCode<T>(        TalerErrorCode.WALLET_RECEIVED_MALFORMED_RESPONSE,        {          requestUrl: httpResponse.requestUrl, +        requestMethod: httpResponse.requestMethod,          httpStatusCode: httpResponse.status,          validationError: e.toString(),        }, @@ -223,11 +225,18 @@ export async function readSuccessResponseJsonOrErrorCode<T>(    };  } +type HttpErrorDetails = { +  requestUrl: string; +  requestMethod: string; +  httpStatusCode: number; +}; +  export function getHttpResponseErrorDetails(    httpResponse: HttpResponse, -): Record<string, unknown> { +): HttpErrorDetails {    return {      requestUrl: httpResponse.requestUrl, +    requestMethod: httpResponse.requestMethod,      httpStatusCode: httpResponse.status,    };  } @@ -240,6 +249,7 @@ export function throwUnexpectedRequestError(      TalerErrorCode.WALLET_UNEXPECTED_REQUEST_ERROR,      {        requestUrl: httpResponse.requestUrl, +      requestMethod: httpResponse.requestMethod,        httpStatusCode: httpResponse.status,        errorResponse: talerErrorResponse,      }, | 
