Template
Fix linking existing VPN clients (WireGuard/service protocols and API errors).
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+8
-2
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user