diff --git a/server/routers/contentstack/accountPage/query.ts b/server/routers/contentstack/accountPage/query.ts index 20aa33dfd..7948c78ad 100644 --- a/server/routers/contentstack/accountPage/query.ts +++ b/server/routers/contentstack/accountPage/query.ts @@ -51,11 +51,15 @@ export const accountPageQueryRouter = router({ ) if (!refsResponse.data) { + const notFoundError = notFound(refsResponse) console.error( "contentstack.accountPage.refs not found error", - JSON.stringify({ query: { lang, uid }, error: refsResponse }) + JSON.stringify({ + query: { lang, uid }, + error: { code: notFoundError.code }, + }) ) - throw notFound(refsResponse) + throw notFoundError } const cleanedData = removeEmptyObjects(refsResponse.data) @@ -93,14 +97,15 @@ export const accountPageQueryRouter = router({ ) if (!response.data) { + const notFoundError = notFound(response) console.error( "contentstack.accountPage not found error", JSON.stringify({ query: { lang, uid }, - error: response, + error: { code: notFoundError.code }, }) ) - throw notFound(response) + throw notFoundError } const validatedAccountPage = validateAccountPageSchema.safeParse( diff --git a/server/routers/contentstack/base/query.ts b/server/routers/contentstack/base/query.ts index fdf1aad8d..8627d57cc 100644 --- a/server/routers/contentstack/base/query.ts +++ b/server/routers/contentstack/base/query.ts @@ -1,3 +1,5 @@ +import { error } from "console" + import { GetContactConfig } from "@/lib/graphql/Query/ContactConfig.graphql" import { GetCurrentFooter, @@ -42,11 +44,12 @@ export const baseQueryRouter = router({ }) if (!response.data) { + const notFoundError = notFound(response) console.error( "contentstack.config not found error", - JSON.stringify({ query: { lang }, error: response }) + JSON.stringify({ query: { lang }, error: { code: notFoundError.code } }) ) - throw notFound(response) + throw notFoundError } const validatedContactConfigConfig = validateContactConfigSchema.safeParse( @@ -101,16 +104,17 @@ export const baseQueryRouter = router({ ) if (!response.data) { + const notFoundError = notFound(response) console.error( "contentstack.header not found error", JSON.stringify({ query: { lang: input.lang, }, - error: response, + error: { code: notFoundError.code }, }) ) - throw notFound(response) + throw notFoundError } const validatedHeaderConfig = validateHeaderConfigSchema.safeParse( @@ -179,16 +183,17 @@ export const baseQueryRouter = router({ ) if (!response.data) { + const notFoundError = notFound(response) console.error( "contentstack.footer not found error", JSON.stringify({ query: { lang: input.lang, }, - error: response, + error: { code: notFoundError.code }, }) ) - throw notFound(response) + throw notFoundError } const validatedFooterConfig = validateFooterConfigSchema.safeParse( diff --git a/server/routers/contentstack/hotelPage/query.ts b/server/routers/contentstack/hotelPage/query.ts index 00f4774b0..bf1f4ca6e 100644 --- a/server/routers/contentstack/hotelPage/query.ts +++ b/server/routers/contentstack/hotelPage/query.ts @@ -19,14 +19,15 @@ export const hotelPageQueryRouter = router({ uid, }) if (!response.data) { + const notFoundError = notFound(response) console.error( "contentstack.hotelPage not found error", JSON.stringify({ query: { lang, uid }, - error: response, + error: { code: notFoundError.code }, }) ) - throw notFound(response) + throw notFoundError } const validatedHotelPage = validateHotelPageSchema.safeParse(response.data) diff --git a/server/routers/contentstack/loyaltyPage/query.ts b/server/routers/contentstack/loyaltyPage/query.ts index bbda342a7..a0c901dd4 100644 --- a/server/routers/contentstack/loyaltyPage/query.ts +++ b/server/routers/contentstack/loyaltyPage/query.ts @@ -55,6 +55,7 @@ export const loyaltyPageQueryRouter = router({ ) if (!refsResponse.data) { + const notFoundError = notFound(refsResponse) console.error( "contentstack.loyaltyPage.refs not found error", JSON.stringify({ @@ -62,10 +63,10 @@ export const loyaltyPageQueryRouter = router({ lang, uid, }, - error: JSON.stringify(refsResponse), + error: { code: notFoundError.code }, }) ) - throw notFound(refsResponse) + throw notFoundError } const cleanedData = removeEmptyObjects(refsResponse.data) @@ -110,14 +111,15 @@ export const loyaltyPageQueryRouter = router({ ) if (!response.data) { + const notFoundError = notFound(response) console.error( "contentstack.loyaltyPage not found error", JSON.stringify({ query: { lang, uid }, - error: response, + error: { code: notFoundError.code }, }) ) - throw notFound(response) + throw notFoundError } const blocks = response.data.loyalty_page.blocks diff --git a/server/routers/contentstack/myPages/navigation/query.ts b/server/routers/contentstack/myPages/navigation/query.ts index 5c751df88..ef9def606 100644 --- a/server/routers/contentstack/myPages/navigation/query.ts +++ b/server/routers/contentstack/myPages/navigation/query.ts @@ -76,16 +76,17 @@ export const navigationQueryRouter = router({ ) if (!refsResponse.data) { + const notFoundError = notFound(refsResponse) console.error( "contentstack.myPages.navigation.refs not found error", JSON.stringify({ query: { lang, }, - error: refsResponse, + error: { code: notFoundError.code }, }) ) - throw notFound(refsResponse) + throw notFoundError } const validatedMyPagesNavigationRefs = @@ -127,13 +128,14 @@ export const navigationQueryRouter = router({ ) if (!response.data) { + const notFoundError = notFound(response) console.error("contentstack.myPages.navigation not found error", { query: { lang, }, - error: response, + error: { code: notFoundError.code }, }) - throw notFound(response) + throw notFoundError } const validatedMyPagesNavigation = navigationPayloadSchema.safeParse( diff --git a/server/routers/hotels/query.ts b/server/routers/hotels/query.ts index 0494178cc..41529c738 100644 --- a/server/routers/hotels/query.ts +++ b/server/routers/hotels/query.ts @@ -54,7 +54,10 @@ export const hotelQueryRouter = router({ "api.hotels.hotel error", JSON.stringify({ query: { hotelId, params: params.toString() }, - error: apiResponse, + error: { + status: apiResponse.status, + statusText: apiResponse.statusText, + }, }) ) return null diff --git a/server/routers/user/query.ts b/server/routers/user/query.ts index df489f2b7..57e4ccd8a 100644 --- a/server/routers/user/query.ts +++ b/server/routers/user/query.ts @@ -54,7 +54,10 @@ async function getVerifiedUser({ session }: { session: Session }) { console.error( "api.user.profile error", JSON.stringify({ - error: apiResponse, + error: { + status: apiResponse.status, + statusText: apiResponse.statusText, + }, }) ) if (apiResponse.status === 401) { @@ -303,7 +306,12 @@ export const userQueryRouter = router({ if (!previousStaysResponse.ok) { console.error( "api.booking.stays.past error", - JSON.stringify({ error: previousStaysResponse }) + JSON.stringify({ + error: { + status: previousStaysResponse.status, + statusText: previousStaysResponse.statusText, + }, + }) ) return notLoggedInUserTrackingData } @@ -383,7 +391,10 @@ export const userQueryRouter = router({ "api.booking.stays.past error ", JSON.stringify({ query: { params: params.toString() }, - error: apiResponse, + error: { + status: apiResponse.status, + statusText: apiResponse.statusText, + }, }) ) return null @@ -463,7 +474,10 @@ export const userQueryRouter = router({ "api.booking.stays.future error ", JSON.stringify({ query: { params: params.toString() }, - error: apiResponse, + error: { + status: apiResponse.status, + statusText: apiResponse.statusText, + }, }) ) return null @@ -532,7 +546,12 @@ export const userQueryRouter = router({ // } console.error( "api.transaction.friendTransactions error ", - JSON.stringify({ error: apiResponse }) + JSON.stringify({ + error: { + status: apiResponse.status, + statusText: apiResponse.statusText, + }, + }) ) return null } @@ -628,7 +647,12 @@ export const userQueryRouter = router({ if (!apiResponse.ok) { console.error( "api.profile.creditCards error ", - JSON.stringify({ error: apiResponse }) + JSON.stringify({ + error: { + status: apiResponse.status, + statusText: apiResponse.statusText, + }, + }) ) return null }