fix(slideshow): surface backend error in the live slideshow card
Log the failing request (status + body) to the console and show the backend error message in the toast instead of a generic "Error", so failures are diagnosable without server log access.
This commit is contained in:
@@ -85,8 +85,10 @@ export const SlideshowSettingsCard: React.FC<SlideshowSettingsCardProps> = ({
|
|||||||
setToken(res.show_share_token);
|
setToken(res.show_share_token);
|
||||||
toast.success(t('slideshow.linkGenerated', 'Slideshow link generated'));
|
toast.success(t('slideshow.linkGenerated', 'Slideshow link generated'));
|
||||||
onChanged?.();
|
onChanged?.();
|
||||||
} catch {
|
} catch (e: any) {
|
||||||
toast.error(t('common.error', 'Something went wrong'));
|
// Surface the real backend reason (the toast otherwise just says "Error").
|
||||||
|
console.error('[slideshow]', e?.response?.status, e?.response?.data || e?.message || e);
|
||||||
|
toast.error(e?.response?.data?.error || t('common.error', 'Something went wrong'));
|
||||||
} finally {
|
} finally {
|
||||||
setBusy(false);
|
setBusy(false);
|
||||||
}
|
}
|
||||||
@@ -102,8 +104,10 @@ export const SlideshowSettingsCard: React.FC<SlideshowSettingsCardProps> = ({
|
|||||||
setToken(null);
|
setToken(null);
|
||||||
toast.success(t('slideshow.linkDisabled', 'Slideshow link disabled'));
|
toast.success(t('slideshow.linkDisabled', 'Slideshow link disabled'));
|
||||||
onChanged?.();
|
onChanged?.();
|
||||||
} catch {
|
} catch (e: any) {
|
||||||
toast.error(t('common.error', 'Something went wrong'));
|
// Surface the real backend reason (the toast otherwise just says "Error").
|
||||||
|
console.error('[slideshow]', e?.response?.status, e?.response?.data || e?.message || e);
|
||||||
|
toast.error(e?.response?.data?.error || t('common.error', 'Something went wrong'));
|
||||||
} finally {
|
} finally {
|
||||||
setBusy(false);
|
setBusy(false);
|
||||||
}
|
}
|
||||||
@@ -141,8 +145,10 @@ export const SlideshowSettingsCard: React.FC<SlideshowSettingsCardProps> = ({
|
|||||||
});
|
});
|
||||||
toast.success(t('slideshow.settingsSaved', 'Slideshow settings saved'));
|
toast.success(t('slideshow.settingsSaved', 'Slideshow settings saved'));
|
||||||
onChanged?.();
|
onChanged?.();
|
||||||
} catch {
|
} catch (e: any) {
|
||||||
toast.error(t('common.error', 'Something went wrong'));
|
// Surface the real backend reason (the toast otherwise just says "Error").
|
||||||
|
console.error('[slideshow]', e?.response?.status, e?.response?.data || e?.message || e);
|
||||||
|
toast.error(e?.response?.data?.error || t('common.error', 'Something went wrong'));
|
||||||
} finally {
|
} finally {
|
||||||
setSaving(false);
|
setSaving(false);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user