From 8b0f3e7fa5a7f5e2e04b962f65631e9a48021b48 Mon Sep 17 00:00:00 2001 From: HinanoAira Date: Sun, 8 Sep 2024 04:11:22 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=82=A8=E3=83=A9=E3=83=BC=E3=83=8F?= =?UTF-8?q?=E3=83=B3=E3=83=89=E3=83=AA=E3=83=B3=E3=82=B0=E3=81=A7=E3=81=AE?= =?UTF-8?q?=E4=BF=9D=E5=AE=88=E6=80=A7=E3=81=AE=E7=A2=BA=E4=BF=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - catchブロックでのeという変数名は混同の危険性があるため利用しない - 保守性のため型チェックでのエラーハンドリングを行う --- .../src/core/entities/NotificationEntityService.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/core/entities/NotificationEntityService.ts b/packages/backend/src/core/entities/NotificationEntityService.ts index c4ddb6efa8..9bade830e2 100644 --- a/packages/backend/src/core/entities/NotificationEntityService.ts +++ b/packages/backend/src/core/entities/NotificationEntityService.ts @@ -5,7 +5,7 @@ import { Inject, Injectable } from '@nestjs/common'; import { ModuleRef } from '@nestjs/core'; -import { In } from 'typeorm'; +import { EntityNotFoundError, In } from 'typeorm'; import { DI } from '@/di-symbols.js'; import type { FollowRequestsRepository, NotesRepository, MiUser, UsersRepository } from '@/models/_.js'; import { awaitAll } from '@/misc/prelude/await-all.js'; @@ -139,9 +139,9 @@ export class NotificationEntityService implements OnModuleInit { // #endregion const needsRole = notification.type === 'roleAssigned'; - const role = needsRole ? await this.roleEntityService.pack(notification.roleId).catch((e) => { - if (e.name === 'EntityNotFoundError') return null; - throw e; + const role = needsRole ? await this.roleEntityService.pack(notification.roleId).catch((err) => { + if (err instanceof EntityNotFoundError) return null; + throw err; }) : undefined; // if the role has been deleted, don't show this notification if (needsRole && !role) {