feat(desktop): improve error feedback on register (show HTTP status + server details); polish form visuals (labels/group/eye toggle)
This commit is contained in:
parent
e3796a4154
commit
dca0a307a2
1 changed files with 11 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue