From dca0a307a2623d588ca083738c82e33a60065259 Mon Sep 17 00:00:00 2001 From: Esdras Renan Date: Fri, 10 Oct 2025 00:36:34 -0300 Subject: [PATCH] feat(desktop): improve error feedback on register (show HTTP status + server details); polish form visuals (labels/group/eye toggle) --- apps/desktop/src/main.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.ts index fed7d5d..e86665e 100644 --- a/apps/desktop/src/main.ts +++ b/apps/desktop/src/main.ts @@ -631,11 +631,18 @@ async function handleRegister(profile: MachineProfile, form: HTMLFormElement) { }) if (!response.ok) { - let message = `Falha ao registrar máquina (${response.status})` + const status = response.status + let message = `Falha ao registrar máquina (${status})` try { - const errorBody = await response.json() - if (errorBody?.error) { - message = errorBody.error + // tenta JSON + const ct = response.headers.get("content-type") || "" + if (ct.includes("application/json")) { + const errorBody = await response.json() + if (errorBody?.error) message = `${message}: ${String(errorBody.error)}` + if (errorBody?.details) message += ` — ${String(errorBody.details)}` + } else { + const text = await response.text() + if (text && text.length < 500) message += ` — ${text}` } } catch { // ignore