From ddb2f228f45d37fa9f39ab858404f2c97da2a77d Mon Sep 17 00:00:00 2001 From: emallson Date: Fri, 12 Apr 2024 18:55:04 -0400 Subject: [PATCH] handle blizzard 403s on character media endpoint this fixes character search. we won't get profile pictures, unfortunately --- src/route/blizzard/index.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/route/blizzard/index.ts b/src/route/blizzard/index.ts index f21d34e..2f46868 100644 --- a/src/route/blizzard/index.ts +++ b/src/route/blizzard/index.ts @@ -9,6 +9,7 @@ import * as cache from "../../cache"; import * as api from "./api"; import { cacheControl } from "../../common/cache-control"; import { AxiosError } from "axios"; +import * as Sentry from "@sentry/node"; type CharacterParams = { id: string; @@ -59,10 +60,19 @@ async function fetchCharacter( } const [media, specs] = await Promise.all([ - api.fetchCharacterMedia(region, realm, name, isClassic), + api.fetchCharacterMedia(region, realm, name, isClassic).catch((error) => { + // not reporting this to sentry because the blizzard api is currently sending 403s from this endpoint to ALL requests + console.error("failed to retrieve character media", error); + return undefined; + }), isClassic ? Promise.resolve(undefined) - : api.fetchCharacterSpecializations(region, realm, name, isClassic), + : api + .fetchCharacterSpecializations(region, realm, name, isClassic) + .catch((error) => { + Sentry.captureException(error); + return undefined; + }), ]); const thumbnailAsset =