fix: sanitize API error text display and add time_blockers tests
Add extractErrorMessage helper for JSON error body parsing and apply sanitizeText across all toast displays. Add time_blockers test coverage for new holiday placeholder cleanup and overlapping scenarios.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import { SvelteDate } from 'svelte/reactivity';
|
||||
import { toast } from 'svelte-sonner';
|
||||
import { extractErrorMessage } from '$lib/utils/toast-safe';
|
||||
import * as Dialog from '$lib/components/ui/dialog';
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import { Input } from '$lib/components/ui/input';
|
||||
@@ -407,7 +408,7 @@
|
||||
});
|
||||
if (!redemptionResponse.ok) {
|
||||
const errData = await redemptionResponse.text();
|
||||
throw new Error(errData || 'Failed to apply loyalty discount');
|
||||
throw new Error(extractErrorMessage(errData) || 'Failed to apply loyalty discount');
|
||||
}
|
||||
} catch (_err) {
|
||||
status = 'error';
|
||||
@@ -452,7 +453,7 @@
|
||||
|
||||
if (!response.ok) {
|
||||
const errData = await response.text();
|
||||
throw new Error(errData || 'Failed to initiate payment');
|
||||
throw new Error(extractErrorMessage(errData) || 'Failed to initiate payment');
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
Reference in New Issue
Block a user