Fix blank error toast

merge-requests/3373/head
Alex Gleason 2025-05-09 14:34:48 -05:00
rodzic e1b3bd0719
commit 7f2c5e87f8
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
2 zmienionych plików z 7 dodań i 3 usunięć

Wyświetl plik

@ -6,7 +6,7 @@ export class HTTPError extends Error {
request: Request;
constructor(response: MastodonResponse, request: Request) {
super(response.statusText);
super(`HTTP Error: ${response.status} ${response.statusText}`);
this.response = response;
this.request = request;
}

Wyświetl plik

@ -2,6 +2,7 @@ import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
import { defineMessages, useIntl } from 'react-intl';
import { create } from 'zustand';
import { HTTPError } from 'soapbox/api/HTTPError.ts';
import { useApi } from 'soapbox/hooks/useApi.ts';
import { NutzappedEntry, NutzappedRecord, Transactions, WalletData, baseWalletSchema, nutzappedEntry, transactionsSchema } from 'soapbox/schemas/wallet.ts';
import toast from 'soapbox/toast.tsx';
@ -210,8 +211,11 @@ const useZapCashuRequest = () => {
await refetch();
},
onError: (err: unknown) => {
const messageError = err instanceof Error ? err.message : 'An unexpected error occurred';
toast.error(messageError);
if (err instanceof HTTPError) {
toast.showAlertForError(err);
} else {
toast.error('An unexpected error occurred');
}
},
});