fix(ui): check ApiError.status instead of message string for 404 detection
All checks were successful
CI / build (push) Successful in 2m3s
CI / docker (push) Successful in 1m27s

The ApiError class (088bc34) extracts messages from response bodies, so
a 404 with no body produces "Request failed" — not "404". The email
connector hook's string check failed, treating "not configured" as an
error and showing "Failed to load config" on fresh installs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-26 21:28:53 +02:00
parent d7ef2c488b
commit e881e302b6

View File

@@ -1,5 +1,5 @@
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
import { api } from './client';
import { api, ApiError } from './client';
export interface EmailConnectorResponse {
connectorId: string;
@@ -32,7 +32,7 @@ export function useEmailConnector() {
try {
return await api.get<EmailConnectorResponse>('/vendor/email-connector');
} catch (e) {
if (e instanceof Error && e.message.includes('404')) return null;
if (e instanceof ApiError && e.status === 404) return null;
throw e;
}
},