Fix linking existing VPN clients (WireGuard/service protocols and API errors).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
orohi
2026-07-26 00:31:57 +03:00
co-authored by Cursor
parent 69886f130c
commit e612a7bc34
8 changed files with 109 additions and 46 deletions
+8 -2
View File
@@ -227,10 +227,16 @@
throw new Error('Session expired');
}
const data = await res.json();
const data = await res.json().catch(() => ({}));
if (!res.ok) {
throw new Error(data.error || 'Unknown error');
const detail = data.error || data.message || data.detail;
const msg = typeof detail === 'string'
? detail
: (Array.isArray(detail)
? detail.map(d => d.msg || JSON.stringify(d)).join('; ')
: (detail ? JSON.stringify(detail) : `HTTP ${res.status}`));
throw new Error(msg || 'Unknown error');
}
return data;
}