Merge branch 'blank-error' into 'main'

Fix blank error toast

See merge request soapbox-pub/soapbox!3373
merge-requests/3372/merge
Alex Gleason 2025-05-09 19:35:46 +00:00
commit bfb203c398
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');
}
},
});