Skip to content

Commit

Permalink
feat: ok
Browse files Browse the repository at this point in the history
  • Loading branch information
mlajkim committed Jan 6, 2025
1 parent 4cc84b0 commit 791ce3b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/domains/action/action-group.domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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'])
}
})()

Expand Down
12 changes: 12 additions & 0 deletions src/errors/400/data-not-selectable.error.ts
Original file line number Diff line number Diff line change
@@ -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
}
}

0 comments on commit 791ce3b

Please sign in to comment.