Merged in chore/add-error-details-for-sentry (pull request #3378)
Include more details when throwing errors for debugging in Sentry * WIP throw errors with more details for debugging in Sentry * Fix throwing response-data * Clearer message when a response fails * Add message to errors * better typings * . * Try to send profileID and membershipNumber to Sentry when we fail to parse the apiResponse * rename notFound -> notFoundError * Merge branch 'master' of bitbucket.org:scandic-swap/web into chore/add-error-details-for-sentry Approved-by: Linus Flood
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { createCounter } from "@scandic-hotels/common/telemetry"
|
||||
|
||||
import { router } from "../../.."
|
||||
import { notFound } from "../../../errors"
|
||||
import { notFoundError } from "../../../errors"
|
||||
import {
|
||||
GetUsePointsModal,
|
||||
GetUsePointsModalRefs,
|
||||
@@ -34,18 +34,22 @@ export const usePointsModalQueryRouter = router({
|
||||
|
||||
metricsRefs.start()
|
||||
const refsTag = generateRefsResponseTag(lang, "usepointsmodal")
|
||||
|
||||
const variables = { locale: lang }
|
||||
const refsResponse = await request<UsePointsModalRefsData>(
|
||||
GetUsePointsModalRefs,
|
||||
{ locale: lang },
|
||||
variables,
|
||||
{
|
||||
key: refsTag,
|
||||
ttl: "max",
|
||||
}
|
||||
)
|
||||
if (!refsResponse.data) {
|
||||
const notFoundError = notFound(refsResponse)
|
||||
metricsRefs.noDataError()
|
||||
throw notFoundError
|
||||
throw notFoundError({
|
||||
message: "GetUsePointsModalRefs returned no data",
|
||||
errorDetails: variables,
|
||||
})
|
||||
}
|
||||
|
||||
const validatedRefsData = usePointsModalRefsSchema.safeParse(
|
||||
@@ -76,7 +80,7 @@ export const usePointsModalQueryRouter = router({
|
||||
|
||||
const response = await request<UsePointsModalData>(
|
||||
GetUsePointsModal,
|
||||
{ locale: lang },
|
||||
variables,
|
||||
{
|
||||
key: tags,
|
||||
ttl: "max",
|
||||
@@ -84,9 +88,11 @@ export const usePointsModalQueryRouter = router({
|
||||
)
|
||||
|
||||
if (!response.data) {
|
||||
const notFoundError = notFound(response)
|
||||
metrics.noDataError()
|
||||
throw notFoundError
|
||||
throw notFoundError({
|
||||
message: "GetUsePointsModal returned no data",
|
||||
errorDetails: variables,
|
||||
})
|
||||
}
|
||||
|
||||
const validatedResponse = usePointsModalSchema.safeParse(response.data)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createCounter } from "@scandic-hotels/common/telemetry"
|
||||
|
||||
import { router } from "../../.."
|
||||
import { notFound } from "../../../errors"
|
||||
import { notFoundError } from "../../../errors"
|
||||
import {
|
||||
GetAccountPage,
|
||||
GetAccountPageRefs,
|
||||
@@ -32,12 +32,10 @@ export const accountPageQueryRouter = router({
|
||||
const metricsRefs = getAccountPageRefsCounter.init({ lang, uid })
|
||||
metricsRefs.start()
|
||||
|
||||
const variables = { locale: lang, uid }
|
||||
const refsResponse = await request<GetAccountPageRefsSchema>(
|
||||
GetAccountPageRefs,
|
||||
{
|
||||
locale: lang,
|
||||
uid,
|
||||
},
|
||||
variables,
|
||||
{
|
||||
key: generateRefsResponseTag(lang, uid),
|
||||
ttl: "max",
|
||||
@@ -45,9 +43,11 @@ export const accountPageQueryRouter = router({
|
||||
)
|
||||
|
||||
if (!refsResponse.data) {
|
||||
const notFoundError = notFound(refsResponse)
|
||||
metricsRefs.noDataError()
|
||||
throw notFoundError
|
||||
throw notFoundError({
|
||||
message: "GetAccountPageRefs returned no data",
|
||||
errorDetails: variables,
|
||||
})
|
||||
}
|
||||
|
||||
const validatedAccountPageRefs = accountPageRefsSchema.safeParse(
|
||||
@@ -75,10 +75,7 @@ export const accountPageQueryRouter = router({
|
||||
|
||||
const response = await request<GetAccountPageSchema>(
|
||||
GetAccountPage,
|
||||
{
|
||||
locale: lang,
|
||||
uid,
|
||||
},
|
||||
variables,
|
||||
{
|
||||
key: tags,
|
||||
ttl: "max",
|
||||
@@ -86,9 +83,12 @@ export const accountPageQueryRouter = router({
|
||||
)
|
||||
|
||||
if (!response.data) {
|
||||
const notFoundError = notFound(response)
|
||||
metrics.noDataError()
|
||||
throw notFoundError
|
||||
|
||||
throw notFoundError({
|
||||
message: "GetAccountPage returned no data",
|
||||
errorDetails: variables,
|
||||
})
|
||||
}
|
||||
|
||||
const validatedAccountPage = accountPageSchema.safeParse(response.data)
|
||||
|
||||
@@ -3,7 +3,7 @@ import { cache } from "react"
|
||||
import { createCounter } from "@scandic-hotels/common/telemetry"
|
||||
|
||||
import { router } from "../../.."
|
||||
import { notFound } from "../../../errors"
|
||||
import { notFoundError } from "../../../errors"
|
||||
import { GetContactConfig } from "../../../graphql/Query/ContactConfig.graphql"
|
||||
import { GetFooter, GetFooterRef } from "../../../graphql/Query/Footer.graphql"
|
||||
import { GetHeader, GetHeaderRef } from "../../../graphql/Query/Header.graphql"
|
||||
@@ -65,12 +65,12 @@ const getContactConfig = cache(async (lang: Lang) => {
|
||||
const metricsGetContactConfig = getContactConfigCounter.init({ lang })
|
||||
|
||||
metricsGetContactConfig.start()
|
||||
|
||||
const variables = {
|
||||
locale: lang,
|
||||
}
|
||||
const response = await request<ContactConfigData>(
|
||||
GetContactConfig,
|
||||
{
|
||||
locale: lang,
|
||||
},
|
||||
variables,
|
||||
{
|
||||
key: `${lang}:contact`,
|
||||
ttl: "max",
|
||||
@@ -78,9 +78,11 @@ const getContactConfig = cache(async (lang: Lang) => {
|
||||
)
|
||||
|
||||
if (!response.data) {
|
||||
const notFoundError = notFound(response)
|
||||
metricsGetContactConfig.noDataError()
|
||||
throw notFoundError
|
||||
throw notFoundError({
|
||||
message: "GetContactConfig returned no data",
|
||||
errorDetails: variables,
|
||||
})
|
||||
}
|
||||
|
||||
const verifiedData = validateContactConfigSchema.safeParse(response.data)
|
||||
@@ -109,21 +111,18 @@ export const baseQueryRouter = router({
|
||||
|
||||
metricsGetHeaderRefs.start()
|
||||
|
||||
const responseRef = await request<GetHeaderRefs>(
|
||||
GetHeaderRef,
|
||||
{
|
||||
locale: lang,
|
||||
},
|
||||
{
|
||||
key: generateRefsResponseTag(lang, "header"),
|
||||
ttl: "max",
|
||||
}
|
||||
)
|
||||
const variables = { locale: lang }
|
||||
const responseRef = await request<GetHeaderRefs>(GetHeaderRef, variables, {
|
||||
key: generateRefsResponseTag(lang, "header"),
|
||||
ttl: "max",
|
||||
})
|
||||
|
||||
if (!responseRef.data) {
|
||||
const notFoundError = notFound(responseRef)
|
||||
metricsGetHeaderRefs.noDataError()
|
||||
throw notFoundError
|
||||
throw notFoundError({
|
||||
message: "GetHeaderRef returned no data",
|
||||
errorDetails: variables,
|
||||
})
|
||||
}
|
||||
|
||||
const validatedHeaderRefs = headerRefsSchema.safeParse(responseRef.data)
|
||||
@@ -147,16 +146,17 @@ export const baseQueryRouter = router({
|
||||
generateTag(lang, validatedHeaderRefs.data.header.system.uid),
|
||||
].flat()
|
||||
|
||||
const response = await request<GetHeaderData>(
|
||||
GetHeader,
|
||||
{ locale: lang },
|
||||
{ key: tags, ttl: "max" }
|
||||
)
|
||||
const response = await request<GetHeaderData>(GetHeader, variables, {
|
||||
key: tags,
|
||||
ttl: "max",
|
||||
})
|
||||
|
||||
if (!response.data) {
|
||||
const notFoundError = notFound(response)
|
||||
metricsGetHeader.noDataError()
|
||||
throw notFoundError
|
||||
throw notFoundError({
|
||||
message: "GetHeader returned no data",
|
||||
errorDetails: variables,
|
||||
})
|
||||
}
|
||||
|
||||
const validatedHeaderConfig = headerSchema.safeParse(response.data)
|
||||
@@ -182,11 +182,10 @@ export const baseQueryRouter = router({
|
||||
|
||||
metricsGetFooterRefs.start()
|
||||
|
||||
const variables = { locale: lang }
|
||||
const responseRef = await request<FooterRefDataRaw>(
|
||||
GetFooterRef,
|
||||
{
|
||||
locale: lang,
|
||||
},
|
||||
variables,
|
||||
{
|
||||
key: generateRefsResponseTag(lang, "footer"),
|
||||
ttl: "max",
|
||||
@@ -194,9 +193,11 @@ export const baseQueryRouter = router({
|
||||
)
|
||||
|
||||
if (!responseRef.data) {
|
||||
const notFoundError = notFound(responseRef)
|
||||
metricsGetFooterRefs.noDataError()
|
||||
throw notFoundError
|
||||
throw notFoundError({
|
||||
message: "GetFooterRef returned no data",
|
||||
errorDetails: variables,
|
||||
})
|
||||
}
|
||||
|
||||
const validatedFooterRefs = validateFooterRefConfigSchema.safeParse(
|
||||
@@ -223,21 +224,17 @@ export const baseQueryRouter = router({
|
||||
generateTag(lang, footerUID),
|
||||
].flat()
|
||||
|
||||
const response = await request<FooterDataRaw>(
|
||||
GetFooter,
|
||||
{
|
||||
locale: lang,
|
||||
},
|
||||
{
|
||||
key: tags,
|
||||
ttl: "max",
|
||||
}
|
||||
)
|
||||
const response = await request<FooterDataRaw>(GetFooter, variables, {
|
||||
key: tags,
|
||||
ttl: "max",
|
||||
})
|
||||
|
||||
if (!response.data) {
|
||||
const notFoundError = notFound(response)
|
||||
metricsGetFooter.noDataError()
|
||||
throw notFoundError
|
||||
throw notFoundError({
|
||||
message: "GetFooter returned no data",
|
||||
errorDetails: variables,
|
||||
})
|
||||
}
|
||||
|
||||
const validatedFooterConfig = validateFooterConfigSchema.safeParse(
|
||||
@@ -269,9 +266,10 @@ export const baseQueryRouter = router({
|
||||
|
||||
metricsGetSitewideCampaignBannerRefs.start()
|
||||
|
||||
const refVariables = { locale: lang }
|
||||
const responseRef = await request<GetSitewideCampaignBannerRefData>(
|
||||
GetSitewideCampaignBannerRef,
|
||||
{ locale: lang },
|
||||
refVariables,
|
||||
{
|
||||
key: generateRefsResponseTag(lang, "sitewide_campaign_banner"),
|
||||
ttl: "max",
|
||||
@@ -279,9 +277,11 @@ export const baseQueryRouter = router({
|
||||
)
|
||||
|
||||
if (!responseRef.data) {
|
||||
const notFoundError = notFound(responseRef)
|
||||
metricsGetSitewideCampaignBannerRefs.noDataError()
|
||||
throw notFoundError
|
||||
throw notFoundError({
|
||||
message: "GetSitewideCampaignBannerRef returned no data",
|
||||
errorDetails: refVariables,
|
||||
})
|
||||
}
|
||||
|
||||
const validatedSitewideCampaignBannerRef =
|
||||
@@ -312,17 +312,21 @@ export const baseQueryRouter = router({
|
||||
|
||||
metricsGetSitewideCampaignBanner.start()
|
||||
|
||||
const variables = { locale: lang }
|
||||
const sitewideCampaignBannerResponse =
|
||||
await request<GetSitewideCampaignBannerData>(
|
||||
GetSitewideCampaignBanner,
|
||||
{ locale: lang },
|
||||
variables,
|
||||
{ key: tags, ttl: "max" }
|
||||
)
|
||||
|
||||
if (!sitewideCampaignBannerResponse.data) {
|
||||
const notFoundError = notFound(sitewideCampaignBannerResponse)
|
||||
metricsGetSitewideCampaignBanner.noDataError()
|
||||
throw notFoundError
|
||||
|
||||
throw notFoundError({
|
||||
message: "GetSitewideCampaignBanner returned no data",
|
||||
errorDetails: variables,
|
||||
})
|
||||
}
|
||||
|
||||
const validatedSitewideCampaignBanner =
|
||||
@@ -354,11 +358,12 @@ export const baseQueryRouter = router({
|
||||
|
||||
metricsGetSiteConfigRefs.start()
|
||||
|
||||
const refVariables = {
|
||||
locale: lang,
|
||||
}
|
||||
const responseRef = await request<GetSiteConfigRefData>(
|
||||
GetSiteConfigRef,
|
||||
{
|
||||
locale: lang,
|
||||
},
|
||||
refVariables,
|
||||
{
|
||||
key: generateRefsResponseTag(lang, "site_config"),
|
||||
ttl: "max",
|
||||
@@ -366,9 +371,11 @@ export const baseQueryRouter = router({
|
||||
)
|
||||
|
||||
if (!responseRef.data) {
|
||||
const notFoundError = notFound(responseRef)
|
||||
metricsGetSiteConfigRefs.noDataError()
|
||||
throw notFoundError
|
||||
throw notFoundError({
|
||||
message: "SiteConfigRefs returned no data",
|
||||
errorDetails: refVariables,
|
||||
})
|
||||
}
|
||||
|
||||
const validatedSiteConfigRef = siteConfigRefSchema.safeParse(
|
||||
@@ -397,24 +404,21 @@ export const baseQueryRouter = router({
|
||||
|
||||
metricsGetSiteConfig.start()
|
||||
|
||||
const variables = { locale: lang }
|
||||
const [siteConfigResponse, contactConfig] = await Promise.all([
|
||||
request<GetSiteConfigData>(
|
||||
GetSiteConfig,
|
||||
{
|
||||
locale: lang,
|
||||
},
|
||||
{
|
||||
key: tags,
|
||||
ttl: "max",
|
||||
}
|
||||
),
|
||||
request<GetSiteConfigData>(GetSiteConfig, variables, {
|
||||
key: tags,
|
||||
ttl: "max",
|
||||
}),
|
||||
getContactConfig(lang),
|
||||
])
|
||||
|
||||
if (!siteConfigResponse.data) {
|
||||
const notFoundError = notFound(siteConfigResponse)
|
||||
metricsGetSiteConfig.noDataError()
|
||||
throw notFoundError
|
||||
throw notFoundError({
|
||||
message: "SiteConfig returned no data",
|
||||
errorDetails: variables,
|
||||
})
|
||||
}
|
||||
|
||||
const validatedSiteConfig = siteConfigSchema.safeParse(
|
||||
|
||||
@@ -5,7 +5,7 @@ import { createCounter } from "@scandic-hotels/common/telemetry"
|
||||
|
||||
import { router } from "../../.."
|
||||
import { PageContentTypeEnum } from "../../../enums/contentType"
|
||||
import { notFound } from "../../../errors"
|
||||
import { notFoundError } from "../../../errors"
|
||||
import {
|
||||
GetMyPagesBreadcrumbs,
|
||||
GetMyPagesBreadcrumbsRefs,
|
||||
@@ -115,19 +115,19 @@ const getBreadcrumbs = cache(async function fetchMemoizedBreadcrumbs<T>(
|
||||
|
||||
metricsGetBreadcrumbs.start()
|
||||
|
||||
const response = await request<T>(
|
||||
query,
|
||||
{ locale: lang, uid },
|
||||
{
|
||||
key: tags,
|
||||
ttl: "max",
|
||||
}
|
||||
)
|
||||
const variables = { locale: lang, uid }
|
||||
const response = await request<T>(query, variables, {
|
||||
key: tags,
|
||||
ttl: "max",
|
||||
})
|
||||
|
||||
if (!response.data) {
|
||||
const notFoundError = notFound(response)
|
||||
metricsGetBreadcrumbs.noDataError()
|
||||
throw notFoundError
|
||||
|
||||
throw notFoundError({
|
||||
message: "Breadcrumbs query returned no data",
|
||||
errorDetails: variables,
|
||||
})
|
||||
}
|
||||
|
||||
const validatedBreadcrumbs = breadcrumbsSchema.safeParse(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createCounter } from "@scandic-hotels/common/telemetry"
|
||||
|
||||
import { router } from "../../.."
|
||||
import { notFound } from "../../../errors"
|
||||
import { notFoundError } from "../../../errors"
|
||||
import {
|
||||
GetCampaignOverviewPage,
|
||||
GetCampaignOverviewPageRefs,
|
||||
@@ -36,9 +36,10 @@ export const campaignOverviewPageQueryRouter = router({
|
||||
|
||||
metricsGetCampaignOverviewPageRefs.start()
|
||||
|
||||
const refVariables = { locale: lang, uid }
|
||||
const refsResponse = await request<GetCampaignOverviewPageRefsData>(
|
||||
GetCampaignOverviewPageRefs,
|
||||
{ locale: lang, uid },
|
||||
refVariables,
|
||||
{
|
||||
key: generateRefsResponseTag(lang, uid),
|
||||
ttl: "max",
|
||||
@@ -46,9 +47,12 @@ export const campaignOverviewPageQueryRouter = router({
|
||||
)
|
||||
|
||||
if (!refsResponse.data) {
|
||||
const notFoundError = notFound(refsResponse)
|
||||
metricsGetCampaignOverviewPageRefs.noDataError()
|
||||
throw notFoundError
|
||||
|
||||
throw notFoundError({
|
||||
message: "GetCampaignOverviewPageRefs returned no data",
|
||||
errorDetails: refVariables,
|
||||
})
|
||||
}
|
||||
|
||||
const validatedRefsData = campaignOverviewPageRefsSchema.safeParse(
|
||||
@@ -75,21 +79,22 @@ export const campaignOverviewPageQueryRouter = router({
|
||||
|
||||
metricsGetCampaignOverviewPage.start()
|
||||
|
||||
const variables = { locale: lang, uid }
|
||||
const response = await request<GetCampaignOverviewPageData>(
|
||||
GetCampaignOverviewPage,
|
||||
{
|
||||
locale: lang,
|
||||
uid,
|
||||
},
|
||||
variables,
|
||||
{
|
||||
key: tags,
|
||||
ttl: "max",
|
||||
}
|
||||
)
|
||||
if (!response.data) {
|
||||
const notFoundError = notFound(response)
|
||||
metricsGetCampaignOverviewPage.noDataError()
|
||||
throw notFoundError
|
||||
|
||||
throw notFoundError({
|
||||
message: "GetCampaignOverviewPage returned no data",
|
||||
errorDetails: variables,
|
||||
})
|
||||
}
|
||||
|
||||
const validatedResponse = campaignOverviewPageSchema.safeParse(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createCounter } from "@scandic-hotels/common/telemetry"
|
||||
|
||||
import { router } from "../../.."
|
||||
import { notFound } from "../../../errors"
|
||||
import { notFoundError } from "../../../errors"
|
||||
import {
|
||||
GetCampaignPage,
|
||||
GetCampaignPageRefs,
|
||||
@@ -32,18 +32,21 @@ export const campaignPageQueryRouter = router({
|
||||
|
||||
metricsGetCampaignPageRefs.start()
|
||||
|
||||
const refVariables = { locale: lang, uid }
|
||||
const refsResponse = await request<GetCampaignPageRefsData>(
|
||||
GetCampaignPageRefs,
|
||||
{ locale: lang, uid },
|
||||
refVariables,
|
||||
{
|
||||
key: generateRefsResponseTag(lang, uid),
|
||||
ttl: "max",
|
||||
}
|
||||
)
|
||||
if (!refsResponse.data) {
|
||||
const notFoundError = notFound(refsResponse)
|
||||
metricsGetCampaignPageRefs.noDataError()
|
||||
throw notFoundError
|
||||
throw notFoundError({
|
||||
message: "GetCampaignPageRefs returned no data",
|
||||
errorDetails: refVariables,
|
||||
})
|
||||
}
|
||||
|
||||
const validatedRefsData = campaignPageRefsSchema.safeParse(
|
||||
@@ -68,21 +71,21 @@ export const campaignPageQueryRouter = router({
|
||||
|
||||
metricsGetCampaignPage.start()
|
||||
|
||||
const variables = { locale: lang, uid }
|
||||
const response = await request<GetCampaignPageData>(
|
||||
GetCampaignPage,
|
||||
{
|
||||
locale: lang,
|
||||
uid,
|
||||
},
|
||||
variables,
|
||||
{
|
||||
key: tags,
|
||||
ttl: "max",
|
||||
}
|
||||
)
|
||||
if (!response.data) {
|
||||
const notFoundError = notFound(response)
|
||||
metricsGetCampaignPage.noDataError()
|
||||
throw notFoundError
|
||||
throw notFoundError({
|
||||
message: "GetCampaignPage returned no data",
|
||||
errorDetails: variables,
|
||||
})
|
||||
}
|
||||
|
||||
const validatedResponse = campaignPageSchema.safeParse(response.data)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { dt } from "@scandic-hotels/common/dt"
|
||||
import { createCounter } from "@scandic-hotels/common/telemetry"
|
||||
|
||||
import { notFound } from "../../../errors"
|
||||
import { notFoundError } from "../../../errors"
|
||||
import {
|
||||
GetCampaignPagesByHotelUid,
|
||||
GetCampaignPagesByHotelUidRefs,
|
||||
@@ -121,13 +121,14 @@ export async function getCampaignPagesByHotelPageUid(
|
||||
`${hotelPageUid}-${today}`,
|
||||
"hotel_page_campaigns"
|
||||
)
|
||||
const variables = {
|
||||
locale: lang,
|
||||
hotelPageUid,
|
||||
today,
|
||||
}
|
||||
const refsResponse = await request<GetCampaignPagesByHotelUidRefsData>(
|
||||
GetCampaignPagesByHotelUidRefs,
|
||||
{
|
||||
locale: lang,
|
||||
hotelPageUid,
|
||||
today,
|
||||
},
|
||||
variables,
|
||||
{
|
||||
key: refsTag,
|
||||
ttl: "1d",
|
||||
@@ -135,9 +136,11 @@ export async function getCampaignPagesByHotelPageUid(
|
||||
)
|
||||
|
||||
if (!refsResponse.data) {
|
||||
const notFoundError = notFound(refsResponse)
|
||||
metricsGetCampaignPagesByHotelUidRefs.noDataError()
|
||||
throw notFoundError
|
||||
throw notFoundError({
|
||||
message: "GetCampaignPagesByHotelUidRefs returned no data",
|
||||
errorDetails: variables,
|
||||
})
|
||||
}
|
||||
|
||||
const validatedRefsData = campaignPagesByHotelUidRefsSchema.safeParse(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { createCounter } from "@scandic-hotels/common/telemetry"
|
||||
|
||||
import { notFound } from "../../../errors"
|
||||
import { notFoundError } from "../../../errors"
|
||||
import { GetCollectionPageRefs } from "../../../graphql/Query/CollectionPage/CollectionPage.graphql"
|
||||
import { request } from "../../../graphql/request"
|
||||
import {
|
||||
@@ -32,13 +32,13 @@ export async function fetchCollectionPageRefs(lang: Lang, uid: string) {
|
||||
metricsGetCollectionPageRefs.start()
|
||||
|
||||
const cacheKey = generateRefsResponseTag(lang, uid)
|
||||
|
||||
const variables = {
|
||||
locale: lang,
|
||||
uid,
|
||||
}
|
||||
const refsResponse = await request<GetCollectionPageRefsSchema>(
|
||||
GetCollectionPageRefs,
|
||||
{
|
||||
locale: lang,
|
||||
uid,
|
||||
},
|
||||
variables,
|
||||
{
|
||||
key: cacheKey,
|
||||
ttl: "max",
|
||||
@@ -46,9 +46,11 @@ export async function fetchCollectionPageRefs(lang: Lang, uid: string) {
|
||||
)
|
||||
|
||||
if (!refsResponse.data) {
|
||||
const notFoundError = notFound(refsResponse)
|
||||
metricsGetCollectionPageRefs.noDataError()
|
||||
throw notFoundError
|
||||
throw notFoundError({
|
||||
message: "GetCollectionPageRefs returned no data",
|
||||
errorDetails: variables,
|
||||
})
|
||||
}
|
||||
|
||||
return refsResponse.data
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { createCounter } from "@scandic-hotels/common/telemetry"
|
||||
|
||||
import { notFound } from "../../../errors"
|
||||
import { notFoundError } from "../../../errors"
|
||||
import { batchRequest } from "../../../graphql/batchRequest"
|
||||
import {
|
||||
GetContentPageBlocksRefs,
|
||||
@@ -34,10 +34,11 @@ export async function fetchContentPageRefs(lang: Lang, uid: string) {
|
||||
|
||||
metricsGetContentPageRefs.start()
|
||||
|
||||
const variables = { locale: lang, uid }
|
||||
const res = await batchRequest<GetContentPageRefsSchema>([
|
||||
{
|
||||
document: GetContentPageRefs,
|
||||
variables: { locale: lang, uid },
|
||||
variables,
|
||||
cacheOptions: {
|
||||
key: generateRefsResponseTag(lang, uid),
|
||||
ttl: "max",
|
||||
@@ -45,7 +46,7 @@ export async function fetchContentPageRefs(lang: Lang, uid: string) {
|
||||
},
|
||||
{
|
||||
document: GetContentPageBlocksRefs,
|
||||
variables: { locale: lang, uid },
|
||||
variables,
|
||||
cacheOptions: {
|
||||
key: generateTag(lang, uid + 1),
|
||||
ttl: "max",
|
||||
@@ -53,9 +54,11 @@ export async function fetchContentPageRefs(lang: Lang, uid: string) {
|
||||
},
|
||||
])
|
||||
if (!res.data) {
|
||||
const notFoundError = notFound(res)
|
||||
metricsGetContentPageRefs.noDataError()
|
||||
throw notFoundError
|
||||
throw notFoundError({
|
||||
message: "GetContentPageRefs/GetContentPageBlocksRefs returned no data",
|
||||
errorDetails: variables,
|
||||
})
|
||||
}
|
||||
|
||||
const validatedData = contentPageRefsSchema.safeParse(res.data)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createCounter } from "@scandic-hotels/common/telemetry"
|
||||
|
||||
import { router } from "../../.."
|
||||
import { notFound } from "../../../errors"
|
||||
import { notFoundError } from "../../../errors"
|
||||
import {
|
||||
GetDestinationCityPage,
|
||||
GetDestinationCityPageRefs,
|
||||
@@ -34,9 +34,10 @@ export const destinationCityPageQueryRouter = router({
|
||||
|
||||
metricsGetDestinationCityPageRefs.start()
|
||||
|
||||
const variables = { locale: lang, uid }
|
||||
const refsResponse = await request<GetDestinationCityPageRefsSchema>(
|
||||
GetDestinationCityPageRefs,
|
||||
{ locale: lang, uid },
|
||||
variables,
|
||||
{
|
||||
key: generateRefsResponseTag(lang, uid),
|
||||
ttl: "max",
|
||||
@@ -44,9 +45,11 @@ export const destinationCityPageQueryRouter = router({
|
||||
)
|
||||
|
||||
if (!refsResponse.data) {
|
||||
const notFoundError = notFound(refsResponse)
|
||||
metricsGetDestinationCityPageRefs.noDataError()
|
||||
throw notFoundError
|
||||
throw notFoundError({
|
||||
message: "GetDestinationCityPageRefs returned no data",
|
||||
errorDetails: variables,
|
||||
})
|
||||
}
|
||||
|
||||
const validatedRefsData = destinationCityPageRefsSchema.safeParse(
|
||||
@@ -73,19 +76,19 @@ export const destinationCityPageQueryRouter = router({
|
||||
|
||||
const response = await request<GetDestinationCityPageData>(
|
||||
GetDestinationCityPage,
|
||||
{
|
||||
locale: lang,
|
||||
uid,
|
||||
},
|
||||
variables,
|
||||
{
|
||||
key: tags,
|
||||
ttl: "max",
|
||||
}
|
||||
)
|
||||
if (!response.data) {
|
||||
const notFoundError = notFound(response)
|
||||
metricsGetDestinationCityPage.noDataError()
|
||||
throw notFoundError
|
||||
|
||||
throw notFoundError({
|
||||
message: "GetDestinationCityPage returned no data",
|
||||
errorDetails: variables,
|
||||
})
|
||||
}
|
||||
|
||||
const validatedResponse = destinationCityPageSchema.safeParse(response.data)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createCounter } from "@scandic-hotels/common/telemetry"
|
||||
|
||||
import { router } from "../../.."
|
||||
import { notFound } from "../../../errors"
|
||||
import { notFoundError } from "../../../errors"
|
||||
import {
|
||||
GetDestinationCountryPage,
|
||||
GetDestinationCountryPageRefs,
|
||||
@@ -38,9 +38,10 @@ export const destinationCountryPageQueryRouter = router({
|
||||
|
||||
metricsGetDestinationCountryPageRefs.start()
|
||||
|
||||
const variables = { locale: lang, uid }
|
||||
const refsResponse = await request<GetDestinationCountryPageRefsSchema>(
|
||||
GetDestinationCountryPageRefs,
|
||||
{ locale: lang, uid },
|
||||
variables,
|
||||
{
|
||||
key: generateRefsResponseTag(lang, uid),
|
||||
ttl: "max",
|
||||
@@ -48,9 +49,11 @@ export const destinationCountryPageQueryRouter = router({
|
||||
)
|
||||
|
||||
if (!refsResponse.data) {
|
||||
const notFoundError = notFound(refsResponse)
|
||||
metricsGetDestinationCountryPageRefs.noDataError()
|
||||
throw notFoundError
|
||||
throw notFoundError({
|
||||
message: "GetDestinationCountryPageRefs returned no data",
|
||||
errorDetails: variables,
|
||||
})
|
||||
}
|
||||
|
||||
const validatedRefsData = destinationCountryPageRefsSchema.safeParse(
|
||||
@@ -77,19 +80,18 @@ export const destinationCountryPageQueryRouter = router({
|
||||
|
||||
const response = await request<GetDestinationCountryPageData>(
|
||||
GetDestinationCountryPage,
|
||||
{
|
||||
locale: lang,
|
||||
uid,
|
||||
},
|
||||
variables,
|
||||
{
|
||||
key: tags,
|
||||
ttl: "max",
|
||||
}
|
||||
)
|
||||
if (!response.data) {
|
||||
const notFoundError = notFound(response)
|
||||
metricsGetDestinationCountryPage.noDataError()
|
||||
throw notFoundError
|
||||
throw notFoundError({
|
||||
message: "GetDestinationCountryPage returned no data",
|
||||
errorDetails: variables,
|
||||
})
|
||||
}
|
||||
|
||||
const validatedResponse = destinationCountryPageSchema.safeParse(
|
||||
|
||||
@@ -2,7 +2,7 @@ import { createCounter } from "@scandic-hotels/common/telemetry"
|
||||
import { safeTry } from "@scandic-hotels/common/utils/safeTry"
|
||||
|
||||
import { router } from "../../.."
|
||||
import { notFound } from "../../../errors"
|
||||
import { notFoundError } from "../../../errors"
|
||||
import {
|
||||
GetDestinationOverviewPage,
|
||||
GetDestinationOverviewPageRefs,
|
||||
@@ -49,21 +49,21 @@ export const destinationOverviewPageQueryRouter = router({
|
||||
|
||||
metricsGetDestinationOverviewPageRefs.start()
|
||||
|
||||
const variables = { locale: lang, uid }
|
||||
const refsResponse = await request<GetDestinationOverviewPageRefsSchema>(
|
||||
GetDestinationOverviewPageRefs,
|
||||
{
|
||||
locale: lang,
|
||||
uid,
|
||||
},
|
||||
variables,
|
||||
{
|
||||
key: generateRefsResponseTag(lang, uid),
|
||||
ttl: "max",
|
||||
}
|
||||
)
|
||||
if (!refsResponse.data) {
|
||||
const notFoundError = notFound(refsResponse)
|
||||
metricsGetDestinationOverviewPageRefs.noDataError()
|
||||
throw notFoundError
|
||||
throw notFoundError({
|
||||
message: "GetDestinationOverviewPageRefs returned no data",
|
||||
errorDetails: variables,
|
||||
})
|
||||
}
|
||||
|
||||
const validatedRefsData = destinationOverviewPageRefsSchema.safeParse(
|
||||
@@ -89,19 +89,18 @@ export const destinationOverviewPageQueryRouter = router({
|
||||
|
||||
const response = await request<GetDestinationOverviewPageData>(
|
||||
GetDestinationOverviewPage,
|
||||
{
|
||||
locale: lang,
|
||||
uid,
|
||||
},
|
||||
variables,
|
||||
{
|
||||
key: generateTag(lang, uid),
|
||||
ttl: "max",
|
||||
}
|
||||
)
|
||||
if (!response.data) {
|
||||
const notFoundError = notFound(response)
|
||||
metricsGetDestinationOverviewPage.noDataError()
|
||||
throw notFoundError
|
||||
throw notFoundError({
|
||||
message: "GetDestinationOverviewPage returned no data",
|
||||
errorDetails: variables,
|
||||
})
|
||||
}
|
||||
|
||||
const destinationOverviewPage = destinationOverviewPageSchema.safeParse(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createCounter } from "@scandic-hotels/common/telemetry"
|
||||
|
||||
import { router } from "../../.."
|
||||
import { notFound } from "../../../errors"
|
||||
import { notFoundError } from "../../../errors"
|
||||
import { GetHotelPage } from "../../../graphql/Query/HotelPage/HotelPage.graphql"
|
||||
import { request } from "../../../graphql/request"
|
||||
import { contentstackExtendedProcedureUID } from "../../../procedures"
|
||||
@@ -21,12 +21,10 @@ export const hotelPageQueryRouter = router({
|
||||
|
||||
metricsGetHotelPage.start()
|
||||
|
||||
const variables = { locale: lang, uid }
|
||||
const hotelPageResponse = await request<GetHotelPageData>(
|
||||
GetHotelPage,
|
||||
{
|
||||
locale: lang,
|
||||
uid,
|
||||
},
|
||||
variables,
|
||||
{
|
||||
key: generateTag(lang, uid),
|
||||
ttl: "max",
|
||||
@@ -34,9 +32,12 @@ export const hotelPageQueryRouter = router({
|
||||
)
|
||||
|
||||
if (!hotelPageResponse.data) {
|
||||
const notFoundError = notFound(hotelPageResponse)
|
||||
metricsGetHotelPage.noDataError()
|
||||
throw notFoundError
|
||||
|
||||
throw notFoundError({
|
||||
message: "GetHotelPage returned no data",
|
||||
errorDetails: variables,
|
||||
})
|
||||
}
|
||||
|
||||
const validatedHotelPage = hotelPageSchema.safeParse(hotelPageResponse.data)
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
import { createCounter } from "@scandic-hotels/common/telemetry"
|
||||
|
||||
import { router } from "../../.."
|
||||
import { notFound } from "../../../errors"
|
||||
import { notFoundError } from "../../../errors"
|
||||
import {
|
||||
GetAllLoyaltyLevels,
|
||||
GetLoyaltyLevel,
|
||||
@@ -48,9 +48,12 @@ export const getAllLoyaltyLevels = cache(async (lang: Lang) => {
|
||||
)
|
||||
|
||||
if (!loyaltyLevelsConfigResponse.data) {
|
||||
const notFoundError = notFound(loyaltyLevelsConfigResponse)
|
||||
metricsGetLoyaltyLevelAll.noDataError()
|
||||
throw notFoundError
|
||||
|
||||
throw notFoundError({
|
||||
message: "GetAllLoyaltyLevels returned no data",
|
||||
errorDetails: { lang, level_ids: allLevelIds },
|
||||
})
|
||||
}
|
||||
|
||||
const validatedLoyaltyLevels = validateLoyaltyLevelsSchema.safeParse(
|
||||
@@ -90,9 +93,11 @@ export const getLoyaltyLevel = cache(
|
||||
!loyaltyLevelsConfigResponse.data ||
|
||||
!loyaltyLevelsConfigResponse.data.all_loyalty_level.items.length
|
||||
) {
|
||||
const notFoundError = notFound(loyaltyLevelsConfigResponse)
|
||||
metricsGetLoyaltyLevel.noDataError()
|
||||
throw notFoundError
|
||||
throw notFoundError({
|
||||
message: "GetLoyaltyLevel returned no data",
|
||||
errorDetails: { lang, level_id },
|
||||
})
|
||||
}
|
||||
|
||||
const validatedLoyaltyLevels = validateLoyaltyLevelsSchema.safeParse(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createCounter } from "@scandic-hotels/common/telemetry"
|
||||
|
||||
import { router } from "../../.."
|
||||
import { notFound } from "../../../errors"
|
||||
import { notFoundError } from "../../../errors"
|
||||
import {
|
||||
GetLoyaltyPage,
|
||||
GetLoyaltyPageRefs,
|
||||
@@ -47,9 +47,11 @@ export const loyaltyPageQueryRouter = router({
|
||||
)
|
||||
|
||||
if (!refsResponse.data) {
|
||||
const notFoundError = notFound(refsResponse)
|
||||
metricsGetLoyaltyPageRefs.noDataError()
|
||||
throw notFoundError
|
||||
throw notFoundError({
|
||||
message: "GetLoyaltyPageRefs returned no data",
|
||||
errorDetails: { ...variables },
|
||||
})
|
||||
}
|
||||
|
||||
const validatedLoyaltyPageRefs = loyaltyPageRefsSchema.safeParse(
|
||||
@@ -86,9 +88,11 @@ export const loyaltyPageQueryRouter = router({
|
||||
)
|
||||
|
||||
if (!response.data) {
|
||||
const notFoundError = notFound(response)
|
||||
metricsGetLoyaltyPage.noDataError()
|
||||
throw notFoundError
|
||||
throw notFoundError({
|
||||
message: "GetLoyaltyPage returned no data",
|
||||
errorDetails: { lang, uid },
|
||||
})
|
||||
}
|
||||
|
||||
const validatedLoyaltyPage = loyaltyPageSchema.safeParse(response.data)
|
||||
|
||||
@@ -4,7 +4,7 @@ import { createCounter } from "@scandic-hotels/common/telemetry"
|
||||
|
||||
import { router } from "../../.."
|
||||
import { PageContentTypeEnum } from "../../../enums/contentType"
|
||||
import { notFound } from "../../../errors"
|
||||
import { notFoundError } from "../../../errors"
|
||||
import { GetAccountPageMetadata } from "../../../graphql/Query/AccountPage/Metadata.graphql"
|
||||
import { GetCampaignOverviewPageMetadata } from "../../../graphql/Query/CampaignOverviewPage/Metadata.graphql"
|
||||
import { GetCampaignPageMetadata } from "../../../graphql/Query/CampaignPage/Metadata.graphql"
|
||||
@@ -51,9 +51,12 @@ const fetchMetadata = cache(async function fetchMemoizedMetadata<T>(
|
||||
)
|
||||
|
||||
if (!response.data) {
|
||||
const notFoundError = notFound(response)
|
||||
metricsGetMetadata.noDataError()
|
||||
throw notFoundError
|
||||
|
||||
throw notFoundError({
|
||||
message: "GetMetadata returned no data",
|
||||
errorDetails: { lang, uid },
|
||||
})
|
||||
}
|
||||
|
||||
metricsGetMetadata.success()
|
||||
|
||||
@@ -3,7 +3,7 @@ import { cache } from "react"
|
||||
import { createCounter } from "@scandic-hotels/common/telemetry"
|
||||
|
||||
import { router } from "../../.."
|
||||
import { notFound } from "../../../errors"
|
||||
import { notFoundError } from "../../../errors"
|
||||
import { GetAllSasTierComparison } from "../../../graphql/Query/SASTierComparison.graphql"
|
||||
import { request } from "../../../graphql/request"
|
||||
import { contentstackBaseProcedure } from "../../../procedures"
|
||||
@@ -36,9 +36,12 @@ export const getSasTierComparison = cache(async (lang: Lang) => {
|
||||
)
|
||||
|
||||
if (!sasTierComparisonConfigResponse.data) {
|
||||
const notFoundError = notFound(sasTierComparisonConfigResponse)
|
||||
metricsGetSasTierComparison.noDataError()
|
||||
throw notFoundError
|
||||
|
||||
throw notFoundError({
|
||||
message: "GetAllSasTierComparison returned no data",
|
||||
errorDetails: { lang },
|
||||
})
|
||||
}
|
||||
|
||||
const validatedSasTierComparison = validateSasTierComparisonSchema.safeParse(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createCounter } from "@scandic-hotels/common/telemetry"
|
||||
|
||||
import { router } from "../../.."
|
||||
import { notFound } from "../../../errors"
|
||||
import { notFoundError } from "../../../errors"
|
||||
import { GetProfilingConsent } from "../../../graphql/Query/ProfilingConsent.graphql"
|
||||
import { request } from "../../../graphql/request"
|
||||
import { contentstackBaseProcedure } from "../../../procedures"
|
||||
@@ -38,9 +38,11 @@ export const profilingConsentQueryRouter = router({
|
||||
}
|
||||
)
|
||||
if (!response.data) {
|
||||
const notFoundError = notFound(response)
|
||||
metricsGetProfilingConsent.noDataError()
|
||||
throw notFoundError
|
||||
throw notFoundError({
|
||||
message: "GetProfilingConsent returned no data",
|
||||
errorDetails: { lang },
|
||||
})
|
||||
}
|
||||
const validatedResponse = profilingConsentSchema.safeParse(response.data)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createCounter } from "@scandic-hotels/common/telemetry"
|
||||
|
||||
import { router } from "../../.."
|
||||
import { notFound } from "../../../errors"
|
||||
import { notFoundError } from "../../../errors"
|
||||
import {
|
||||
GetPromoCampaignPage,
|
||||
GetPromoCampaignPageRefs,
|
||||
@@ -42,9 +42,11 @@ export const promoCampaignPageQueryRouter = router({
|
||||
}
|
||||
)
|
||||
if (!refsResponse.data) {
|
||||
const notFoundError = notFound(refsResponse)
|
||||
metricsGetPromoCampaignPageRefs.noDataError()
|
||||
throw notFoundError
|
||||
throw notFoundError({
|
||||
message: "GetPromoCampaignPageRefs returned no data",
|
||||
errorDetails: { lang, uid },
|
||||
})
|
||||
}
|
||||
|
||||
const validatedRefsData = promoCampaignPageRefsSchema.safeParse(
|
||||
@@ -81,9 +83,11 @@ export const promoCampaignPageQueryRouter = router({
|
||||
}
|
||||
)
|
||||
if (!response.data) {
|
||||
const notFoundError = notFound(response)
|
||||
metricsGetPromoCampaignPage.noDataError()
|
||||
throw notFoundError
|
||||
throw notFoundError({
|
||||
message: "GetPromoCampaignPage returned no data",
|
||||
errorDetails: { lang, uid },
|
||||
})
|
||||
}
|
||||
|
||||
const validatedResponse = promoCampaignPageSchema.safeParse(response.data)
|
||||
|
||||
@@ -2,7 +2,7 @@ import { createCounter } from "@scandic-hotels/common/telemetry"
|
||||
|
||||
import { router } from "../../.."
|
||||
import * as api from "../../../api"
|
||||
import { notFound } from "../../../errors"
|
||||
import { notFoundError } from "../../../errors"
|
||||
import {
|
||||
contentStackBaseWithProtectedProcedure,
|
||||
contentStackBaseWithServiceProcedure,
|
||||
@@ -92,7 +92,7 @@ export const rewardQueryRouter = router({
|
||||
metricsGetContentstackRewardAll.dataError(
|
||||
`Failed to matched loyalty level between API and CMS for level ${level}`
|
||||
)
|
||||
throw notFound()
|
||||
throw notFoundError()
|
||||
}
|
||||
const result: LevelWithRewards = {
|
||||
...levelConfig,
|
||||
|
||||
@@ -2,7 +2,7 @@ import { getCacheClient } from "@scandic-hotels/common/dataCache"
|
||||
import { createCounter } from "@scandic-hotels/common/telemetry"
|
||||
|
||||
import * as api from "../../../api"
|
||||
import { notFound } from "../../../errors"
|
||||
import { notFoundError } from "../../../errors"
|
||||
import {
|
||||
GetRewards as GetRewards,
|
||||
GetRewardsRef as GetRewardsRef,
|
||||
@@ -109,9 +109,12 @@ export async function getCmsRewards(lang: Lang, rewardIds: string[]) {
|
||||
)
|
||||
|
||||
if (!refsResponse.data) {
|
||||
const notFoundError = notFound(refsResponse)
|
||||
metricsGetContentstackRewardAllRefs.noDataError()
|
||||
throw notFoundError
|
||||
|
||||
throw notFoundError({
|
||||
message: "GetRewardsRef returned no data",
|
||||
errorDetails: { lang, rewardIds },
|
||||
})
|
||||
}
|
||||
|
||||
const validatedRefsData = rewardRefsSchema.safeParse(refsResponse)
|
||||
@@ -144,9 +147,12 @@ export async function getCmsRewards(lang: Lang, rewardIds: string[]) {
|
||||
)
|
||||
|
||||
if (!cmsRewardsResponse.data) {
|
||||
const notFoundError = notFound(cmsRewardsResponse)
|
||||
metricsGetContentstackRewardAll.noDataError()
|
||||
throw notFoundError
|
||||
|
||||
throw notFoundError({
|
||||
message: "GetRewards not found",
|
||||
errorDetails: { lang, rewardIds },
|
||||
})
|
||||
}
|
||||
|
||||
const validatedCmsRewards =
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createCounter } from "@scandic-hotels/common/telemetry"
|
||||
|
||||
import { router } from "../../.."
|
||||
import { notFound } from "../../../errors"
|
||||
import { notFoundError } from "../../../errors"
|
||||
import {
|
||||
GetStartPage,
|
||||
GetStartPageRefs,
|
||||
@@ -54,9 +54,11 @@ export const startPageQueryRouter = router({
|
||||
}
|
||||
)
|
||||
if (!refsResponse.data) {
|
||||
const notFoundError = notFound(refsResponse)
|
||||
metricsGetStartPageRefs.noDataError()
|
||||
throw notFoundError
|
||||
throw notFoundError({
|
||||
message: "StartPage refs returned no data",
|
||||
errorDetails: { lang, uid },
|
||||
})
|
||||
}
|
||||
|
||||
const validatedRefsData = startPageRefsSchema.safeParse(refsResponse.data)
|
||||
@@ -95,9 +97,11 @@ export const startPageQueryRouter = router({
|
||||
)
|
||||
|
||||
if (!response.data) {
|
||||
const notFoundError = notFound(response)
|
||||
metricsGetStartPage.noDataError()
|
||||
throw notFoundError
|
||||
throw notFoundError({
|
||||
message: "StartPage not found",
|
||||
errorDetails: { lang, uid },
|
||||
})
|
||||
}
|
||||
|
||||
const startPage = startPageSchema.safeParse(response.data)
|
||||
|
||||
Reference in New Issue
Block a user