caldav 2026.08.27.03 — filters on calendar and contacts
This commit is contained in:
@@ -228,7 +228,19 @@ const handleRevokedSession = (url: string) => {
|
||||
const validateResponse = async (res: Response) => {
|
||||
if (res.status >= 400) {
|
||||
const { onError } = useClient.config;
|
||||
const message = await res.text();
|
||||
// Read the body ONCE, as text, and parse it ourselves — a Response body cannot be read twice.
|
||||
// The platform answers `{ error: string }` since 2026-08-25, but a plugin's own routes and any
|
||||
// non-Hono surface still answer plain text, so the raw text stays as the fallback.
|
||||
const body = await res.text();
|
||||
let message = body;
|
||||
try {
|
||||
const parsed: unknown = JSON.parse(body);
|
||||
if (parsed && typeof parsed === 'object' && typeof (parsed as { error?: unknown }).error === 'string') {
|
||||
message = (parsed as { error: string }).error;
|
||||
}
|
||||
} catch {
|
||||
// Not JSON — keep the text as-is.
|
||||
}
|
||||
if (onError) {
|
||||
onError({ status: res.status, message });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user