Skip to content

Commit 927af8a

Browse files
authored
capture internal api error (#119)
1 parent 3adcc84 commit 927af8a

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/routes/status.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { RaidHubRoute } from "@/core/RaidHubRoute"
22
import { getDestiny2Status } from "@/integrations/bungie"
33
import { InternalApiError } from "@/lib/utils/internal-api-client"
4+
import { Logger } from "@/lib/utils/logging"
45
import { cacheControl } from "@/middleware/cache-control"
56
import {
67
AtlasStatus,
@@ -15,6 +16,8 @@ import { getInstanceBasic } from "@/services/instance/instance"
1516
import { getLatestInstanceByDate } from "@/services/instance/latest"
1617
import { z } from "zod"
1718

19+
const logger = new Logger("STATUS_ROUTE")
20+
1821
// This state tracks the status of the Destiny API and debounces it with a grace period of 60 seconds.
1922
export const statusState = {
2023
debounce: 60000,
@@ -103,6 +106,13 @@ export const statusRoute = new RaidHubRoute({
103106
})
104107
} catch (err) {
105108
if (err instanceof InternalApiError) {
109+
// log the error as a error for sentry
110+
logger.error("INTERNAL_API_ERROR", err, {
111+
serviceName: err.serviceName,
112+
url: err.url.toString(),
113+
status: err.status,
114+
statusText: err.statusText
115+
})
106116
return RaidHubRoute.fail(ErrorCode.ServiceUnavailableError, {
107117
serviceName: err.serviceName,
108118
message: "Internal service unavailable"

0 commit comments

Comments
 (0)