fix(ui): check ApiError.status instead of message string for 404 detection
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:
@@ -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;
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user