import { HttpException, HttpStatus } from '@nestjs/common' const NAMED_PARAMETER_REGEX = new RegExp(/(:)\w+/g) const ERROR_MESSAGE_TEMPLATE = 'Argument :arg is required' export class RequiredArgumentError extends HttpException { constructor(...args: Array) { super( { status: HttpStatus.UNPROCESSABLE_ENTITY, message: args.map(arg => ERROR_MESSAGE_TEMPLATE.replace(NAMED_PARAMETER_REGEX, arg)).join(', '), }, HttpStatus.UNPROCESSABLE_ENTITY, ) } }