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:
Joakim Jäderberg
2026-01-12 09:01:44 +00:00
parent 575763aaa2
commit 99537b13e8
37 changed files with 641 additions and 293 deletions

View File

@@ -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)