From 791ce3b8f7144f87d6d069034ed3106ce1f64f5b Mon Sep 17 00:00:00 2001 From: AJ Kim Date: Mon, 6 Jan 2025 09:06:45 +0900 Subject: [PATCH] feat: ok --- src/domains/action/action-group.domain.ts | 3 ++- src/errors/400/data-not-selectable.error.ts | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/errors/400/data-not-selectable.error.ts diff --git a/src/domains/action/action-group.domain.ts b/src/domains/action/action-group.domain.ts index cf40364..bdb3059 100644 --- a/src/domains/action/action-group.domain.ts +++ b/src/domains/action/action-group.domain.ts @@ -28,6 +28,7 @@ import { NotExistOrNoPermissionError } from '@/errors/404/not-exist-or-no-permis import { SupportedTimeZoneConst } from '@/constants/time-zone.const' import { NumberNotInRangeError } from '@/errors/400/index.num-not-in-range.error' import { PostActionBodyDTO } from '@/dto/post-action.dto' +import { DataNotSelectableError } from '@/errors/400/data-not-selectable.error' /** * ActionGroupDomain first contains only level 1~4 data. @@ -289,7 +290,7 @@ export class ActionGroupDomain extends DomainRoot { case 'yesterday': return timeHandler.getStartOfYesterday(this.props.timezone) default: - throw new BadRequestError('Invalid which') + throw new DataNotSelectableError('which', ['today', 'yesterday']) } })() diff --git a/src/errors/400/data-not-selectable.error.ts b/src/errors/400/data-not-selectable.error.ts new file mode 100644 index 0000000..503ee26 --- /dev/null +++ b/src/errors/400/data-not-selectable.error.ts @@ -0,0 +1,12 @@ +import { BadRequestError } from './index.error' + +/** Thrown when certain data is not acceptable + * @example + * throw new DataNotSelectableError('which', ['today', 'yesterday']) + * => Invalid key [which]: Only acceptable in [today, yesterday] + */ +export class DataNotSelectableError extends BadRequestError { + constructor(key: string, acceptable: string[]) { + super(`Invalid key [${key}]: Only acceptable in [${acceptable.toString()}]`) // i.e) User email is not present + } +}