diff --git a/web/src/api/buster_rest/errors.ts b/web/src/api/buster_rest/errors.ts index ba4315ff6..6de4c4078 100644 --- a/web/src/api/buster_rest/errors.ts +++ b/web/src/api/buster_rest/errors.ts @@ -34,4 +34,5 @@ export const rustErrorHandler = (errors: any = {}): RustApiError => { export interface RustApiError { message?: string; + status?: number; } diff --git a/web/src/api/createServerInstance.ts b/web/src/api/createServerInstance.ts index 302208fcb..09c58d3f2 100644 --- a/web/src/api/createServerInstance.ts +++ b/web/src/api/createServerInstance.ts @@ -4,6 +4,7 @@ import { BASE_URL } from './buster_rest/config'; import type { RequestInit } from 'next/dist/server/web/spec-extension/request'; import { createClient } from '@/lib/supabase/server'; import { cookies } from 'next/headers'; +import { RustApiError } from './buster_rest/errors'; export interface FetchConfig extends RequestInit { baseURL?: string; @@ -40,11 +41,10 @@ export const serverFetch = async (url: string, config: FetchConfig = {}): Pro }); if (!response.ok) { - const errorCode = response.status; - const errorMessage = response.statusText; - throw new Error(`HTTP error! ${errorMessage}`, { - cause: errorMessage - }); + throw { + status: response.status, + message: response.statusText + } satisfies RustApiError; } return response.json(); diff --git a/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/metrics/[metricId]/page.tsx b/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/metrics/[metricId]/page.tsx index 68d6f329b..ed79c2624 100644 --- a/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/metrics/[metricId]/page.tsx +++ b/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/metrics/[metricId]/page.tsx @@ -12,14 +12,7 @@ export default async function Page(props: { const queryClient = await prefetchGetMetric({ id: metricId }); - const data = queryClient.getQueryData(queryKeys.metricsGetMetric(metricId).queryKey); - const state = queryClient.getQueryState(queryKeys.metricsGetMetric(metricId).queryKey); - const errorMessage = state?.error?.message; - const errorCode = state?.error; - - console.log('data-------', data); - console.log('state error message-------', errorMessage); - console.log('state error code-------', errorCode); + // const state = queryClient.getQueryState(queryKeys.metricsGetMetric(metricId).queryKey); return (