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

@@ -2,7 +2,12 @@ import { createCounter } from "@scandic-hotels/common/telemetry"
import { router } from "../.."
import * as api from "../../api"
import { badRequestError, serverErrorByStatus } from "../../errors"
import {
badRequestError,
extractResponseDetails,
notFoundError,
serverErrorByStatus,
} from "../../errors"
import { createRefIdPlugin } from "../../plugins/refIdToConfirmationNumber"
import {
safeProtectedServiceProcedure,
@@ -85,8 +90,10 @@ export const bookingQueryRouter = router({
hotelId: booking.hotelId,
}
)
throw serverErrorByStatus(404)
throw notFoundError({
message: "Hotel data not found",
errorDetails: { hotelId: booking.hotelId },
})
}
metricsGetBooking.success()
@@ -163,7 +170,10 @@ export const bookingQueryRouter = router({
}
)
throw serverErrorByStatus(404)
throw notFoundError({
message: "Hotel data not found",
errorDetails: { hotelId: booking.hotelId },
})
}
metricsFindBooking.success()
@@ -265,14 +275,22 @@ export const bookingQueryRouter = router({
if (!apiResponse.ok) {
await metricsGetBookingStatus.httpError(apiResponse)
throw serverErrorByStatus(apiResponse.status, apiResponse)
throw serverErrorByStatus(
apiResponse.status,
await extractResponseDetails(apiResponse),
"getBookingStatus failed"
)
}
const apiJson = await apiResponse.json()
const verifiedData = createBookingSchema.safeParse(apiJson)
if (!verifiedData.success) {
metricsGetBookingStatus.validationError(verifiedData.error)
throw badRequestError()
throw badRequestError({
message: "Invalid booking data",
errorDetails: verifiedData.error.formErrors,
})
}
metricsGetBookingStatus.success()