summaryrefslogtreecommitdiff
path: root/packages/demobank-ui/src/utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/demobank-ui/src/utils.ts')
-rw-r--r--packages/demobank-ui/src/utils.ts18
1 files changed, 12 insertions, 6 deletions
diff --git a/packages/demobank-ui/src/utils.ts b/packages/demobank-ui/src/utils.ts
index 4ce0f140e..c13b9a3cb 100644
--- a/packages/demobank-ui/src/utils.ts
+++ b/packages/demobank-ui/src/utils.ts
@@ -16,11 +16,12 @@
import { HttpStatusCode, TranslatedString } from "@gnu-taler/taler-util";
import {
+ ErrorNotification,
ErrorType,
HttpError,
useTranslationContext,
} from "@gnu-taler/web-util/browser";
-import { ErrorMessage } from "./hooks/notification.js";
+
/**
* Validate (the number part of) an amount. If needed,
@@ -120,11 +121,12 @@ export function buildRequestErrorMessage(
onClientError?: (status: HttpStatusCode) => TranslatedString | undefined;
onServerError?: (status: HttpStatusCode) => TranslatedString | undefined;
} = {},
-): ErrorMessage {
- let result: ErrorMessage;
+): ErrorNotification {
+ let result: ErrorNotification;
switch (cause.type) {
case ErrorType.TIMEOUT: {
result = {
+ type: "error",
title: i18n.str`Request timeout`,
};
break;
@@ -133,8 +135,9 @@ export function buildRequestErrorMessage(
const title =
specialCases.onClientError && specialCases.onClientError(cause.status);
result = {
+ type: "error",
title: title ? title : i18n.str`The server didn't accept the request`,
- description: cause?.payload?.error?.description,
+ description: cause?.payload?.error?.description as TranslatedString,
debug: JSON.stringify(cause),
};
break;
@@ -143,24 +146,27 @@ export function buildRequestErrorMessage(
const title =
specialCases.onServerError && specialCases.onServerError(cause.status);
result = {
+ type: "error",
title: title
? title
: i18n.str`The server had problems processing the request`,
- description: cause?.payload?.error?.description,
+ description: cause?.payload?.error?.description as TranslatedString,
debug: JSON.stringify(cause),
};
break;
}
case ErrorType.UNREADABLE: {
result = {
+ type: "error",
title: i18n.str`Unexpected error`,
- description: `Response from ${cause?.info?.url} is unreadable, status: ${cause?.status}`,
+ description: `Response from ${cause?.info?.url} is unreadable, status: ${cause?.status}` as TranslatedString,
debug: JSON.stringify(cause),
};
break;
}
case ErrorType.UNEXPECTED: {
result = {
+ type: "error",
title: i18n.str`Unexpected error`,
debug: JSON.stringify(cause),
};