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 {
|
||||
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(
|
||||
|
||||
Reference in New Issue
Block a user