Show actual API error details in modal save/create failures

Previously modals showed generic "Failed to add/save" messages. Now they
extract and display the actual error detail from the API response (e.g.,
"URL is required", "Name already exists"). Handles Pydantic validation
arrays by joining msg fields.

Fixed in 8 files: device-discovery, devices, calibration,
advanced-calibration, scene-presets, automations, command-palette.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-18 15:19:08 +03:00
parent cdba98813b
commit f4647027d2
7 changed files with 61 additions and 31 deletions

View File

@@ -172,11 +172,13 @@ export async function saveAdvancedCalibration() {
_modal.forceClose();
} else {
const err = await resp.json().catch(() => ({}));
showToast(err.message || t('calibration.error.save_failed'), 'error');
const detail = err.detail || err.message || '';
const detailStr = Array.isArray(detail) ? detail.map(d => d.msg || d).join('; ') : String(detail);
showToast(detailStr || t('calibration.error.save_failed'), 'error');
}
} catch (error) {
if (error.isAuth) return;
showToast(t('calibration.error.save_failed'), 'error');
showToast(error.message || t('calibration.error.save_failed'), 'error');
}
}