aboutsummaryrefslogtreecommitdiff
path: root/packages/web-util/src
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2024-09-02 14:59:09 -0300
committerSebastian <sebasjm@gmail.com>2024-09-02 14:59:23 -0300
commitb52b13ddae1dfcb2866f0e55de5617681165b7de (patch)
treeef127ca69f125cb57b36340ad628fb255b6667bd /packages/web-util/src
parent5bdefcf53d0bbad5b3c9474fab9b0cfa6eafeae9 (diff)
when error happen there is no garantee that taler error details is present, so undefined should be set
Diffstat (limited to 'packages/web-util/src')
-rw-r--r--packages/web-util/src/context/bank-api.ts6
-rw-r--r--packages/web-util/src/context/challenger-api.ts6
-rw-r--r--packages/web-util/src/context/exchange-api.ts6
-rw-r--r--packages/web-util/src/context/merchant-api.ts6
-rw-r--r--packages/web-util/src/hooks/useNotifications.ts2
5 files changed, 21 insertions, 5 deletions
diff --git a/packages/web-util/src/context/bank-api.ts b/packages/web-util/src/context/bank-api.ts
index 978eba171..e610b49e0 100644
--- a/packages/web-util/src/context/bank-api.ts
+++ b/packages/web-util/src/context/bank-api.ts
@@ -192,7 +192,11 @@ function buildBankApiClient(
async function getRemoteConfig(): Promise<TalerCorebankConfigResponse> {
const resp = await bank.getConfig();
if (resp.type === "fail") {
- throw TalerError.fromUncheckedDetail(resp.detail);
+ if (resp.detail) {
+ throw TalerError.fromUncheckedDetail(resp.detail);
+ } else {
+ throw TalerError.fromException(new Error("failed to get bank remote config"))
+ }
}
return resp.body;
}
diff --git a/packages/web-util/src/context/challenger-api.ts b/packages/web-util/src/context/challenger-api.ts
index 8748f5f69..e2a6e05c3 100644
--- a/packages/web-util/src/context/challenger-api.ts
+++ b/packages/web-util/src/context/challenger-api.ts
@@ -183,7 +183,11 @@ function buildChallengerApiClient(
async function getRemoteConfig(): Promise<ChallengerApi.ChallengerTermsOfServiceResponse> {
const resp = await challenger.getConfig();
if (resp.type === "fail") {
- throw TalerError.fromUncheckedDetail(resp.detail);
+ if (resp.detail) {
+ throw TalerError.fromUncheckedDetail(resp.detail);
+ } else {
+ throw TalerError.fromException(new Error("failed to get challenger remote config"))
+ }
}
return resp.body;
}
diff --git a/packages/web-util/src/context/exchange-api.ts b/packages/web-util/src/context/exchange-api.ts
index 39f889ba9..967b042f9 100644
--- a/packages/web-util/src/context/exchange-api.ts
+++ b/packages/web-util/src/context/exchange-api.ts
@@ -187,7 +187,11 @@ function buildExchangeApiClient(
async function getRemoteConfig(): Promise<TalerExchangeApi.ExchangeVersionResponse> {
const resp = await ex.getConfig();
if (resp.type === "fail") {
- throw TalerError.fromUncheckedDetail(resp.detail);
+ if (resp.detail) {
+ throw TalerError.fromUncheckedDetail(resp.detail);
+ } else {
+ throw TalerError.fromException(new Error("failed to get exchange remote config"))
+ }
}
return resp.body;
}
diff --git a/packages/web-util/src/context/merchant-api.ts b/packages/web-util/src/context/merchant-api.ts
index 09d1d6adc..8d929ae12 100644
--- a/packages/web-util/src/context/merchant-api.ts
+++ b/packages/web-util/src/context/merchant-api.ts
@@ -198,7 +198,11 @@ function buildMerchantApiClient(
async function getRemoteConfig(): Promise<TalerMerchantApi.TalerMerchantConfigResponse> {
const resp = await instance.getConfig();
if (resp.type === "fail") {
- throw TalerError.fromUncheckedDetail(resp.detail);
+ if (resp.detail) {
+ throw TalerError.fromUncheckedDetail(resp.detail);
+ } else {
+ throw TalerError.fromException(new Error("failed to get merchant remote config"))
+ }
}
return resp.body;
}
diff --git a/packages/web-util/src/hooks/useNotifications.ts b/packages/web-util/src/hooks/useNotifications.ts
index 103b88c86..929c54a58 100644
--- a/packages/web-util/src/hooks/useNotifications.ts
+++ b/packages/web-util/src/hooks/useNotifications.ts
@@ -155,7 +155,7 @@ function errorMap<T extends OperationFail<unknown>>(
notify({
type: "error",
title: map(resp.case),
- description: resp.detail.hint as TranslatedString,
+ description: (resp.detail?.hint as TranslatedString) ?? "",
debug: resp.detail,
when: AbsoluteTime.now(),
});