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