feat(desktop): improve error feedback on register (show HTTP status + server details); polish form visuals (labels/group/eye toggle)

This commit is contained in:
Esdras Renan 2025-10-10 00:36:34 -03:00
parent e3796a4154
commit dca0a307a2

View file

@ -631,11 +631,18 @@ async function handleRegister(profile: MachineProfile, form: HTMLFormElement) {
}) })
if (!response.ok) { 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 { try {
// tenta JSON
const ct = response.headers.get("content-type") || ""
if (ct.includes("application/json")) {
const errorBody = await response.json() const errorBody = await response.json()
if (errorBody?.error) { if (errorBody?.error) message = `${message}: ${String(errorBody.error)}`
message = errorBody.error if (errorBody?.details) message += `${String(errorBody.details)}`
} else {
const text = await response.text()
if (text && text.length < 500) message += `${text}`
} }
} catch { } catch {
// ignore // ignore