From b86bd81ed2be71050a934808e20dcb221a08aefe Mon Sep 17 00:00:00 2001 From: "P. Reis" Date: Wed, 9 Oct 2024 19:19:54 -0300 Subject: [PATCH] refactor: cast correct error type --- src/controllers/api/translate.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/api/translate.ts b/src/controllers/api/translate.ts index 5f229e0e..e1577478 100644 --- a/src/controllers/api/translate.ts +++ b/src/controllers/api/translate.ts @@ -132,8 +132,8 @@ const translateController: AppController = async (c) => { dittoTranslations.set(translatedId, { data: mastodonTranslation }); return c.json(mastodonTranslation, 200); - } catch (e: any) { - if (e.message?.includes('not supported')) { + } catch (e) { + if (e instanceof Error && e.message?.includes('not supported')) { return c.json({ error: `Translation of source language '${event.language}' not supported` }, 422); } return c.json({ error: 'Service Unavailable' }, 503);