fix: add improved logging for contentstack requests
This commit is contained in:
@@ -8,11 +8,16 @@ import { HotelPage, HotelPageDataRaw, validateHotelPageSchema } from "./output"
|
||||
export const hotelPageQueryRouter = router({
|
||||
get: contentstackBaseProcedure.query(async ({ ctx }) => {
|
||||
const { lang, uid } = ctx
|
||||
console.info("contentstack.hotelPage start ", JSON.stringify({ lang, uid }))
|
||||
const response = await request<HotelPageDataRaw>(GetHotelPage, {
|
||||
locale: lang,
|
||||
uid,
|
||||
})
|
||||
if (!response.data) {
|
||||
console.error(
|
||||
"contentstack.hotelPage not found error",
|
||||
JSON.stringify({ lang, uid })
|
||||
)
|
||||
throw notFound(response)
|
||||
}
|
||||
|
||||
@@ -20,9 +25,10 @@ export const hotelPageQueryRouter = router({
|
||||
|
||||
if (!validatedHotelPage.success) {
|
||||
console.error(
|
||||
`Failed to validate Hotel Page - (uid: ${uid}, lang: ${lang})`
|
||||
"contentstack.hotelPage validation error",
|
||||
JSON.stringify({ lang, uid }),
|
||||
JSON.stringify(validatedHotelPage.error)
|
||||
)
|
||||
console.error(validatedHotelPage.error)
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user