diff --git a/dictation_server/src/features/auth/errors/types.ts b/dictation_server/src/features/auth/errors/types.ts index 969d13a..9b8c164 100644 --- a/dictation_server/src/features/auth/errors/types.ts +++ b/dictation_server/src/features/auth/errors/types.ts @@ -1,6 +1,21 @@ // Role文字列想定外エラー -export class RoleUnexpectedError extends Error {} +export class RoleUnexpectedError extends Error { + constructor(message: string) { + super(message); + this.name = 'RoleUnexpectedError'; + } +} // Tier範囲想定外エラー -export class TierUnexpectedError extends Error {} +export class TierUnexpectedError extends Error { + constructor(message: string) { + super(message); + this.name = 'TierUnexpectedError'; + } +} // トークン形式不正エラー -export class InvalidTokenFormatError extends Error {} +export class InvalidTokenFormatError extends Error { + constructor(message: string) { + super(message); + this.name = 'InvalidTokenFormatError'; + } +} diff --git a/dictation_server/src/features/files/errors/types.ts b/dictation_server/src/features/files/errors/types.ts index 735e11c..f4ea092 100644 --- a/dictation_server/src/features/files/errors/types.ts +++ b/dictation_server/src/features/files/errors/types.ts @@ -1,12 +1,42 @@ // 音声ファイル不在エラー -export class AudioFileNotFoundError extends Error {} +export class AudioFileNotFoundError extends Error { + constructor(message: string) { + super(message); + this.name = 'AudioFileNotFoundError'; + } +} // テンプレートファイル不在エラー -export class TemplateFileNotFoundError extends Error {} +export class TemplateFileNotFoundError extends Error { + constructor(message: string) { + super(message); + this.name = 'TemplateFileNotFoundError'; + } +} // Account不一致エラー -export class AccountNotMatchError extends Error {} +export class AccountNotMatchError extends Error { + constructor(message: string) { + super(message); + this.name = 'AccountNotMatchError'; + } +} // Status不一致エラー -export class StatusNotMatchError extends Error {} +export class StatusNotMatchError extends Error { + constructor(message: string) { + super(message); + this.name = 'StatusNotMatchError'; + } +} // Author不一致エラー -export class AuthorUserNotMatchError extends Error {} +export class AuthorUserNotMatchError extends Error { + constructor(message: string) { + super(message); + this.name = 'AuthorUserNotMatchError'; + } +} // TypistUser不一致エラー -export class TypistUserNotMatchError extends Error {} +export class TypistUserNotMatchError extends Error { + constructor(message: string) { + super(message); + this.name = 'TypistUserNotMatchError'; + } +} diff --git a/dictation_server/src/features/licenses/licenses.service.spec.ts b/dictation_server/src/features/licenses/licenses.service.spec.ts index 27a2458..7804d71 100644 --- a/dictation_server/src/features/licenses/licenses.service.spec.ts +++ b/dictation_server/src/features/licenses/licenses.service.spec.ts @@ -128,7 +128,9 @@ describe('LicensesService', () => { it('POナンバー重複時、エラーとなる', async () => { const lisencesRepositoryMockValue = makeDefaultLicensesRepositoryMockValue(); - lisencesRepositoryMockValue.order = new PoNumberAlreadyExistError(); + lisencesRepositoryMockValue.order = new PoNumberAlreadyExistError( + `This PoNumber already used`, + ); const usersRepositoryMockValue = makeDefaultUsersRepositoryMockValue(); const accountsRepositoryMockValue = makeDefaultAccountsRepositoryMockValue(); @@ -260,8 +262,9 @@ describe('LicensesService', () => { it('カードライセンス取り込みに失敗した場合、エラーになる(ライセンスが存在しないエラー)', async () => { const lisencesRepositoryMockValue = makeDefaultLicensesRepositoryMockValue(); - lisencesRepositoryMockValue.activateCardLicense = - new LicenseNotExistError(); + lisencesRepositoryMockValue.activateCardLicense = new LicenseNotExistError( + `License not exist`, + ); const usersRepositoryMockValue = makeDefaultUsersRepositoryMockValue(); const accountsRepositoryMockValue = makeDefaultAccountsRepositoryMockValue(); @@ -284,7 +287,7 @@ describe('LicensesService', () => { const lisencesRepositoryMockValue = makeDefaultLicensesRepositoryMockValue(); lisencesRepositoryMockValue.activateCardLicense = - new LicenseKeyAlreadyActivatedError(); + new LicenseKeyAlreadyActivatedError(`License already activated`); const usersRepositoryMockValue = makeDefaultUsersRepositoryMockValue(); const accountsRepositoryMockValue = makeDefaultAccountsRepositoryMockValue(); diff --git a/dictation_server/src/features/tasks/errors/types.ts b/dictation_server/src/features/tasks/errors/types.ts index a9faba0..ad6b3d9 100644 --- a/dictation_server/src/features/tasks/errors/types.ts +++ b/dictation_server/src/features/tasks/errors/types.ts @@ -1,2 +1,7 @@ // ロール不正エラー -export class InvalidRoleError extends Error {} +export class InvalidRoleError extends Error { + constructor(message: string) { + super(message); + this.name = 'InvalidRoleError'; + } +} diff --git a/dictation_server/src/features/users/users.service.spec.ts b/dictation_server/src/features/users/users.service.spec.ts index 0ede204..83894ee 100644 --- a/dictation_server/src/features/users/users.service.spec.ts +++ b/dictation_server/src/features/users/users.service.spec.ts @@ -330,8 +330,9 @@ describe('UsersService.confirmUserAndInitPassword', () => { const configMockValue = makeDefaultConfigValue(); const sortCriteriaRepositoryMockValue = makeDefaultSortCriteriaRepositoryMockValue(); - usersRepositoryMockValue.updateUserVerified = - new EmailAlreadyVerifiedError(); + usersRepositoryMockValue.updateUserVerified = new EmailAlreadyVerifiedError( + `Email already verified user`, + ); const service = await makeUsersServiceMock( usersRepositoryMockValue, diff --git a/dictation_server/src/gateways/redis/redis.service.ts b/dictation_server/src/gateways/redis/redis.service.ts index 10653d0..1d0e402 100644 --- a/dictation_server/src/gateways/redis/redis.service.ts +++ b/dictation_server/src/gateways/redis/redis.service.ts @@ -22,8 +22,7 @@ export class RedisService { ): Promise { this.logger.log( `[IN] [${context.getTrackingId()}] ${this.set.name} | params: { ` + - `ttl: ${ttl} - };`, + `ttl: ${ttl} };`, ); try { @@ -34,6 +33,8 @@ export class RedisService { await this.cacheManager.set(key, value, { ttl: ttl } as any); } catch (error) { this.logger.error(`[${context.getTrackingId()}] ${error}`); + } finally { + this.logger.log(`[OUT] [${context.getTrackingId()}] ${this.set.name}`); } } @@ -50,8 +51,7 @@ export class RedisService { ): Promise { this.logger.log( `[IN] [${context.getTrackingId()}] ${this.mset.name} | params: { ` + - `ttl: ${ttl} - };`, + `ttl: ${ttl} };`, ); try { @@ -62,6 +62,8 @@ export class RedisService { } } catch (error) { this.logger.error(`[${context.getTrackingId()}] ${error}`); + } finally { + this.logger.log(`[OUT] [${context.getTrackingId()}] ${this.mset.name}`); } } @@ -80,6 +82,8 @@ export class RedisService { } catch (error) { this.logger.error(`[${context.getTrackingId()}] ${error}`); return undefined; + } finally { + this.logger.log(`[OUT] [${context.getTrackingId()}] ${this.get.name}`); } } @@ -109,6 +113,8 @@ export class RedisService { } catch (error) { this.logger.error(`[${context.getTrackingId()}] ${error}`); return []; + } finally { + this.logger.log(`[OUT] [${context.getTrackingId()}] ${this.mget.name}`); } } @@ -123,6 +129,8 @@ export class RedisService { await this.cacheManager.del(key); } catch (error) { this.logger.error(`[${context.getTrackingId()}] ${error}`); + } finally { + this.logger.log(`[OUT] [${context.getTrackingId()}] ${this.del.name}`); } } } diff --git a/dictation_server/src/repositories/accounts/accounts.repository.service.ts b/dictation_server/src/repositories/accounts/accounts.repository.service.ts index 8380461..1df7d13 100644 --- a/dictation_server/src/repositories/accounts/accounts.repository.service.ts +++ b/dictation_server/src/repositories/accounts/accounts.repository.service.ts @@ -216,7 +216,7 @@ export class AccountsRepositoryService { }); if (!account) { - throw new AccountNotFoundError(); + throw new AccountNotFoundError(`Account is Not Found.`); } return account; } @@ -525,7 +525,7 @@ export class AccountsRepositoryService { }, }); if (!ownAccount) { - throw new AccountNotFoundError(); + throw new AccountNotFoundError(`Account is Not Found.`); } // 自アカウントのライセンス注文状況を取得する @@ -947,7 +947,7 @@ export class AccountsRepositoryService { // ワークタイプが存在しない場合はエラー if (!worktype) { - throw new WorktypeIdNotFoundError('Worktype is not found. id: ${id}'); + throw new WorktypeIdNotFoundError(`Worktype is not found. id: ${id}`); } } diff --git a/dictation_server/src/repositories/accounts/errors/types.ts b/dictation_server/src/repositories/accounts/errors/types.ts index d35f16f..826700c 100644 --- a/dictation_server/src/repositories/accounts/errors/types.ts +++ b/dictation_server/src/repositories/accounts/errors/types.ts @@ -1,8 +1,28 @@ // アカウント未発見エラー -export class AccountNotFoundError extends Error {} +export class AccountNotFoundError extends Error { + constructor(message: string) { + super(message); + this.name = 'AccountNotFoundError'; + } +} // ディーラーアカウント未存在エラー -export class DealerAccountNotFoundError extends Error {} +export class DealerAccountNotFoundError extends Error { + constructor(message: string) { + super(message); + this.name = 'DealerAccountNotFoundError'; + } +} // 管理者ユーザ未存在エラー -export class AdminUserNotFoundError extends Error {} +export class AdminUserNotFoundError extends Error { + constructor(message: string) { + super(message); + this.name = 'AdminUserNotFoundError'; + } +} // アカウントロックエラー -export class AccountLockedError extends Error {} +export class AccountLockedError extends Error { + constructor(message: string) { + super(message); + this.name = 'AccountLockedError'; + } +} diff --git a/dictation_server/src/repositories/licenses/errors/types.ts b/dictation_server/src/repositories/licenses/errors/types.ts index 331ece1..12b34d1 100644 --- a/dictation_server/src/repositories/licenses/errors/types.ts +++ b/dictation_server/src/repositories/licenses/errors/types.ts @@ -1,38 +1,108 @@ // POナンバーがすでに存在するエラー -export class PoNumberAlreadyExistError extends Error {} +export class PoNumberAlreadyExistError extends Error { + constructor(message: string) { + super(message); + this.name = 'PoNumberAlreadyExistError'; + } +} // 取り込むカードライセンスが存在しないエラー -export class LicenseNotExistError extends Error {} +export class LicenseNotExistError extends Error { + constructor(message: string) { + super(message); + this.name = 'LicenseNotExistError'; + } +} // 取り込むライセンスが既に取り込み済みのエラー -export class LicenseKeyAlreadyActivatedError extends Error {} +export class LicenseKeyAlreadyActivatedError extends Error { + constructor(message: string) { + super(message); + this.name = 'LicenseKeyAlreadyActivatedError'; + } +} // 注文不在エラー -export class OrderNotFoundError extends Error {} +export class OrderNotFoundError extends Error { + constructor(message: string) { + super(message); + this.name = 'OrderNotFoundError'; + } +} // 注文発行済エラー -export class AlreadyIssuedError extends Error {} +export class AlreadyIssuedError extends Error { + constructor(message: string) { + super(message); + this.name = 'AlreadyIssuedError'; + } +} // ライセンス不足エラー -export class LicensesShortageError extends Error {} +export class LicensesShortageError extends Error { + constructor(message: string) { + super(message); + this.name = 'LicensesShortageError'; + } +} // ライセンス有効期限切れエラー -export class LicenseExpiredError extends Error {} +export class LicenseExpiredError extends Error { + constructor(message: string) { + super(message); + this.name = 'LicenseExpiredError'; + } +} // ライセンス割り当て不可エラー -export class LicenseUnavailableError extends Error {} +export class LicenseUnavailableError extends Error { + constructor(message: string) { + super(message); + this.name = 'LicenseUnavailableError'; + } +} // ライセンス割り当て解除済みエラー -export class LicenseAlreadyDeallocatedError extends Error {} +export class LicenseAlreadyDeallocatedError extends Error { + constructor(message: string) { + super(message); + this.name = 'LicenseAlreadyDeallocatedError'; + } +} // 注文キャンセル失敗エラー -export class CancelOrderFailedError extends Error {} +export class CancelOrderFailedError extends Error { + constructor(message: string) { + super(message); + this.name = 'CancelOrderFailedError'; + } +} // ライセンス発行キャンセル不可エラー(ステータスが変えられている場合) -export class AlreadyLicenseStatusChangedError extends Error {} +export class AlreadyLicenseStatusChangedError extends Error { + constructor(message: string) { + super(message); + this.name = 'AlreadyLicenseStatusChangedError'; + } +} // ライセンス発行キャンセル不可エラー(発行から一定期間経過した場合) -export class CancellationPeriodExpiredError extends Error {} +export class CancellationPeriodExpiredError extends Error { + constructor(message: string) { + super(message); + this.name = 'CancellationPeriodExpiredError'; + } +} // ライセンス発行キャンセル不可エラー(発行したライセンスが割り当てされている場合) -export class AlreadyLicenseAllocatedError extends Error {} +export class AlreadyLicenseAllocatedError extends Error { + constructor(message: string) { + super(message); + this.name = 'AlreadyLicenseAllocatedError'; + } +} // ライセンス未割当エラー -export class LicenseNotAllocatedError extends Error {} +export class LicenseNotAllocatedError extends Error { + constructor(message: string) { + super(message); + this.name = 'LicenseNotAllocatedError'; + } +} diff --git a/dictation_server/src/repositories/licenses/licenses.repository.service.ts b/dictation_server/src/repositories/licenses/licenses.repository.service.ts index c43fa47..6f107fc 100644 --- a/dictation_server/src/repositories/licenses/licenses.repository.service.ts +++ b/dictation_server/src/repositories/licenses/licenses.repository.service.ts @@ -73,7 +73,7 @@ export class LicensesRepositoryService { }); // 重複があった場合はエラーを返却する if (isPoNumberDuplicated) { - throw new PoNumberAlreadyExistError(); + throw new PoNumberAlreadyExistError(`This PoNumber already used.`); } const repo = entityManager.getRepository(LicenseOrder); @@ -239,14 +239,14 @@ export class LicensesRepositoryService { this.logger.error( `card license key not exist. card_licence_key: ${licenseKey}`, ); - throw new LicenseNotExistError(); + throw new LicenseNotExistError(`License not exist.`); } // 既に取り込み済みならエラー if (targetCardLicense.activated_at) { this.logger.error( `card license already activated. card_licence_key: ${licenseKey}`, ); - throw new LicenseKeyAlreadyActivatedError(); + throw new LicenseKeyAlreadyActivatedError(`License already activated.`); } const licensesRepo = entityManager.getRepository(License); @@ -262,7 +262,7 @@ export class LicensesRepositoryService { this.logger.error( `license not exist. licence_id: ${targetCardLicense.license_id}`, ); - throw new LicenseNotExistError(); + throw new LicenseNotExistError(`License not exist.`); } // ライセンステーブルを更新する diff --git a/dictation_server/src/repositories/sort_criteria/sort_criteria.repository.service.ts b/dictation_server/src/repositories/sort_criteria/sort_criteria.repository.service.ts index c1dc4fb..fb3252d 100644 --- a/dictation_server/src/repositories/sort_criteria/sort_criteria.repository.service.ts +++ b/dictation_server/src/repositories/sort_criteria/sort_criteria.repository.service.ts @@ -34,7 +34,7 @@ export class SortCriteriaRepositoryService { }); // 運用上はあり得ないが、プログラム上発生しうるのでエラーとして処理 if (!targetSortCriteria) { - throw new Error('sort criteria not found '); + throw new Error('sort criteria not found.'); } targetSortCriteria.parameter = parameter; @@ -60,7 +60,7 @@ export class SortCriteriaRepositoryService { }); // 運用上はあり得ないが、プログラム上発生しうるのでエラーとして処理 if (!sortCriteria) { - throw new Error('sort criteria not found '); + throw new Error('sort criteria not found.'); } return sortCriteria; diff --git a/dictation_server/src/repositories/tasks/errors/types.ts b/dictation_server/src/repositories/tasks/errors/types.ts index b82c3ed..7b4aa78 100644 --- a/dictation_server/src/repositories/tasks/errors/types.ts +++ b/dictation_server/src/repositories/tasks/errors/types.ts @@ -1,18 +1,63 @@ // タイピストグループ未発見エラー -export class TypistUserGroupNotFoundError extends Error {} +export class TypistUserGroupNotFoundError extends Error { + constructor(message: string) { + super(message); + this.name = 'TypistUserGroupNotFoundError'; + } +} // タイピストユーザー未発見エラー -export class TypistUserNotFoundError extends Error {} +export class TypistUserNotFoundError extends Error { + constructor(message: string) { + super(message); + this.name = 'TypistUserNotFoundError'; + } +} // タスク未発見エラー -export class TasksNotFoundError extends Error {} +export class TasksNotFoundError extends Error { + constructor(message: string) { + super(message); + this.name = 'TasksNotFoundError'; + } +} // タスクAuthorID不一致エラー -export class TaskAuthorIdNotMatchError extends Error {} +export class TaskAuthorIdNotMatchError extends Error { + constructor(message: string) { + super(message); + this.name = 'TaskAuthorIdNotMatchError'; + } +} // チェックアウト権限未発見エラー -export class CheckoutPermissionNotFoundError extends Error {} +export class CheckoutPermissionNotFoundError extends Error { + constructor(message: string) { + super(message); + this.name = 'CheckoutPermissionNotFoundError'; + } +} // Status不一致エラー -export class StatusNotMatchError extends Error {} +export class StatusNotMatchError extends Error { + constructor(message: string) { + super(message); + this.name = 'StatusNotMatchError'; + } +} // TypistUser不一致エラー -export class TypistUserNotMatchError extends Error {} +export class TypistUserNotMatchError extends Error { + constructor(message: string) { + super(message); + this.name = 'TypistUserNotMatchError'; + } +} // Account不一致エラー -export class AccountNotMatchError extends Error {} +export class AccountNotMatchError extends Error { + constructor(message: string) { + super(message); + this.name = 'AccountNotMatchError'; + } +} // タスクチェックアウト済みエラー -export class AlreadyHasInProgressTaskError extends Error {} +export class AlreadyHasInProgressTaskError extends Error { + constructor(message: string) { + super(message); + this.name = 'AlreadyHasInProgressTaskError'; + } +} diff --git a/dictation_server/src/repositories/tasks/tasks.repository.service.ts b/dictation_server/src/repositories/tasks/tasks.repository.service.ts index 784dcec..3e6fd6f 100644 --- a/dictation_server/src/repositories/tasks/tasks.repository.service.ts +++ b/dictation_server/src/repositories/tasks/tasks.repository.service.ts @@ -190,7 +190,7 @@ export class TasksRepositoryService { ); } if (!isTaskStatus(task.status)) { - throw new Error('invalid task status'); + throw new Error('invalid task status.'); } // ステータスチェック if (!permittedSourceStatus.includes(task.status)) { @@ -340,7 +340,7 @@ export class TasksRepositoryService { ); } if (!isTaskStatus(task.status)) { - throw new Error('invalid task status'); + throw new Error('invalid task status.'); } // ステータスチェック if (!permittedSourceStatus.includes(task.status)) { diff --git a/dictation_server/src/repositories/template_files/errors/types.ts b/dictation_server/src/repositories/template_files/errors/types.ts index 52896de..d1db4d7 100644 --- a/dictation_server/src/repositories/template_files/errors/types.ts +++ b/dictation_server/src/repositories/template_files/errors/types.ts @@ -1,2 +1,7 @@ // テンプレートファイルが存在しないエラー -export class TemplateFileNotExistError extends Error {} +export class TemplateFileNotExistError extends Error { + constructor(message: string) { + super(message); + this.name = 'TemplateFileNotExistError'; + } +} diff --git a/dictation_server/src/repositories/user_groups/errors/types.ts b/dictation_server/src/repositories/user_groups/errors/types.ts index a41ff78..57aabbb 100644 --- a/dictation_server/src/repositories/user_groups/errors/types.ts +++ b/dictation_server/src/repositories/user_groups/errors/types.ts @@ -1,4 +1,14 @@ // タイピストグループが存在しないエラー -export class TypistGroupNotExistError extends Error {} +export class TypistGroupNotExistError extends Error { + constructor(message: string) { + super(message); + this.name = 'TypistGroupNotExistError'; + } +} // typistIdが不正な場合のエラー -export class TypistIdInvalidError extends Error {} +export class TypistIdInvalidError extends Error { + constructor(message: string) { + super(message); + this.name = 'TypistIdInvalidError'; + } +} diff --git a/dictation_server/src/repositories/users/errors/types.ts b/dictation_server/src/repositories/users/errors/types.ts index 32c1af0..6f90ede 100644 --- a/dictation_server/src/repositories/users/errors/types.ts +++ b/dictation_server/src/repositories/users/errors/types.ts @@ -1,16 +1,56 @@ // Email検証済みエラー -export class EmailAlreadyVerifiedError extends Error {} +export class EmailAlreadyVerifiedError extends Error { + constructor(message: string) { + super(message); + this.name = 'EmailAlreadyVerifiedError'; + } +} // ユーザー未発見エラー -export class UserNotFoundError extends Error {} +export class UserNotFoundError extends Error { + constructor(message: string) { + super(message); + this.name = 'UserNotFoundError'; + } +} // AuthorID重複エラー -export class AuthorIdAlreadyExistsError extends Error {} +export class AuthorIdAlreadyExistsError extends Error { + constructor(message: string) { + super(message); + this.name = 'AuthorIdAlreadyExistsError'; + } +} // 不正なRole変更エラー -export class InvalidRoleChangeError extends Error {} +export class InvalidRoleChangeError extends Error { + constructor(message: string) { + super(message); + this.name = 'InvalidRoleChangeError'; + } +} // 暗号化パスワード不足エラー -export class EncryptionPasswordNeedError extends Error {} +export class EncryptionPasswordNeedError extends Error { + constructor(message: string) { + super(message); + this.name = 'EncryptionPasswordNeedError'; + } +} // 利用規約バージョン情報不在エラー -export class TermInfoNotFoundError extends Error {} +export class TermInfoNotFoundError extends Error { + constructor(message: string) { + super(message); + this.name = 'TermInfoNotFoundError'; + } +} // 利用規約バージョンパラメータ不在エラー -export class UpdateTermsVersionNotSetError extends Error {} +export class UpdateTermsVersionNotSetError extends Error { + constructor(message: string) { + super(message); + this.name = 'UpdateTermsVersionNotSetError'; + } +} // 代行操作不許可エラー -export class DelegationNotAllowedError extends Error {} +export class DelegationNotAllowedError extends Error { + constructor(message: string) { + super(message); + this.name = 'DelegationNotAllowedError'; + } +} diff --git a/dictation_server/src/repositories/users/users.repository.service.ts b/dictation_server/src/repositories/users/users.repository.service.ts index ed202a5..97787de 100644 --- a/dictation_server/src/repositories/users/users.repository.service.ts +++ b/dictation_server/src/repositories/users/users.repository.service.ts @@ -136,7 +136,7 @@ export class UsersRepositoryService { }); if (!user) { - throw new UserNotFoundError(); + throw new UserNotFoundError(`User not Found.`); } return user; } @@ -189,7 +189,7 @@ export class UsersRepositoryService { // 運用上ユーザがいないことはあり得ないが、プログラム上発生しうるのでエラーとして処理 if (!targetUser) { - throw new UserNotFoundError(); + throw new UserNotFoundError(`User not Found.`); } // ユーザーのロールがNoneの場合以外はロールを変更できない @@ -267,11 +267,11 @@ export class UsersRepositoryService { // 運用上ユーザがいないことはあり得ないが、プログラム上発生しうるのでエラーとして処理 if (!targetUser) { - throw new UserNotFoundError(); + throw new UserNotFoundError(`User not Found.`); } if (targetUser.email_verified) { - throw new EmailAlreadyVerifiedError(); + throw new EmailAlreadyVerifiedError(`Email already verified user.`); } targetUser.email_verified = true; @@ -299,11 +299,11 @@ export class UsersRepositoryService { // 運用上ユーザがいないことはあり得ないが、プログラム上発生しうるのでエラーとして処理 if (!targetUser) { - throw new UserNotFoundError(); + throw new UserNotFoundError(`User not Found.`); } if (targetUser.email_verified) { - throw new EmailAlreadyVerifiedError(); + throw new EmailAlreadyVerifiedError(`Email already verified user.`); } targetUser.email_verified = true; @@ -382,7 +382,7 @@ export class UsersRepositoryService { // 運用上ユーザがいないことはあり得ないが、プログラム上発生しうるのでエラーとして処理 if (!user) { - throw new UserNotFoundError(); + throw new UserNotFoundError(`User not Found.`); } const typists = await repo.find({ @@ -456,7 +456,7 @@ export class UsersRepositoryService { }); if (!user) { - throw new UserNotFoundError(); + throw new UserNotFoundError(`User not Found.`); } if (!user.account) { throw new AccountNotFoundError('Account is Not Found.'); diff --git a/dictation_server/src/repositories/workflows/errors/types.ts b/dictation_server/src/repositories/workflows/errors/types.ts index 633bc00..1ffa5aa 100644 --- a/dictation_server/src/repositories/workflows/errors/types.ts +++ b/dictation_server/src/repositories/workflows/errors/types.ts @@ -1,4 +1,14 @@ // AuthorIDとWorktypeIDのペア重複エラー -export class AuthorIdAndWorktypeIdPairAlreadyExistsError extends Error {} +export class AuthorIdAndWorktypeIdPairAlreadyExistsError extends Error { + constructor(message: string) { + super(message); + this.name = 'AuthorIdAndWorktypeIdPairAlreadyExistsError'; + } +} // Workflow存在エラー -export class WorkflowNotFoundError extends Error {} +export class WorkflowNotFoundError extends Error { + constructor(message: string) { + super(message); + this.name = 'WorkflowNotFoundError'; + } +} diff --git a/dictation_server/src/repositories/workflows/workflows.repository.service.ts b/dictation_server/src/repositories/workflows/workflows.repository.service.ts index fb9cb9b..a1ea660 100644 --- a/dictation_server/src/repositories/workflows/workflows.repository.service.ts +++ b/dictation_server/src/repositories/workflows/workflows.repository.service.ts @@ -97,7 +97,7 @@ export class WorkflowsRepositoryService { where: { account_id: accountId, id: templateId }, }); if (!template) { - throw new TemplateFileNotExistError('template not found'); + throw new TemplateFileNotExistError('template not found.'); } } @@ -144,7 +144,7 @@ export class WorkflowsRepositoryService { }); if (workflow.length !== 0) { throw new AuthorIdAndWorktypeIdPairAlreadyExistsError( - 'workflow already exists', + 'workflow already exists.', ); } @@ -288,7 +288,7 @@ export class WorkflowsRepositoryService { }); if (duplicateWorkflow.length !== 0) { throw new AuthorIdAndWorktypeIdPairAlreadyExistsError( - 'workflow already exists', + 'workflow already exists.', ); } } diff --git a/dictation_server/src/repositories/worktypes/errors/types.ts b/dictation_server/src/repositories/worktypes/errors/types.ts index 6fe60c1..fb5db2d 100644 --- a/dictation_server/src/repositories/worktypes/errors/types.ts +++ b/dictation_server/src/repositories/worktypes/errors/types.ts @@ -1,8 +1,28 @@ // WorktypeID重複エラー -export class WorktypeIdAlreadyExistsError extends Error {} +export class WorktypeIdAlreadyExistsError extends Error { + constructor(message: string) { + super(message); + this.name = 'WorktypeIdAlreadyExistsError'; + } +} // WorktypeID登録上限エラー -export class WorktypeIdMaxCountError extends Error {} +export class WorktypeIdMaxCountError extends Error { + constructor(message: string) { + super(message); + this.name = 'WorktypeIdMaxCountError'; + } +} // WorktypeID不在エラー -export class WorktypeIdNotFoundError extends Error {} +export class WorktypeIdNotFoundError extends Error { + constructor(message: string) { + super(message); + this.name = 'WorktypeIdNotFoundError'; + } +} // WorktypeID使用中エラー -export class WorktypeIdInUseError extends Error {} +export class WorktypeIdInUseError extends Error { + constructor(message: string) { + super(message); + this.name = 'WorktypeIdInUseError'; + } +} diff --git a/dictation_server/src/repositories/worktypes/worktypes.repository.service.ts b/dictation_server/src/repositories/worktypes/worktypes.repository.service.ts index 616f9e0..38016c1 100644 --- a/dictation_server/src/repositories/worktypes/worktypes.repository.service.ts +++ b/dictation_server/src/repositories/worktypes/worktypes.repository.service.ts @@ -39,7 +39,7 @@ export class WorktypesRepositoryService { // 運用上アカウントがいないことはあり得ないが、プログラム上発生しうるのでエラーとして処理 if (!account) { - throw new AccountNotFoundError(); + throw new AccountNotFoundError('Account is Not Found.'); } const worktypes = await WorktypeRepo.find({