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