UNPKG

@sapphire/framework

Version:

Discord bot framework built for advanced and amazing bots.

1 lines 1.91 kB
{"version":3,"sources":["../../../../src/lib/errors/ArgumentError.ts"],"names":[],"mappings":";;;AAQO,IAAM,cAAA,GAAN,MAAM,cAAA,SAAmC,SAAU,CAAA;AAAA,EAIlD,YAAY,OAAmC,EAAA;AACrD,IAAM,KAAA,CAAA,EAAE,GAAG,OAAS,EAAA,UAAA,EAAY,QAAQ,UAAc,IAAA,OAAA,CAAQ,QAAS,CAAA,IAAA,EAAM,CAAA;AAC7E,IAAA,IAAA,CAAK,WAAW,OAAQ,CAAA,QAAA;AACxB,IAAA,IAAA,CAAK,YAAY,OAAQ,CAAA,SAAA;AAAA;AAC1B;AAAA,EAGA,IAAoB,IAAe,GAAA;AAClC,IAAO,OAAA,eAAA;AAAA;AAET,CAAA;AAd0D,MAAA,CAAA,cAAA,EAAA,eAAA,CAAA;AAAnD,IAAM,aAAN,GAAA","file":"ArgumentError.mjs","sourcesContent":["import type { IArgument } from '../structures/Argument';\nimport { UserError } from './UserError';\n\n/**\n * Errors thrown by the argument parser\n * @since 1.0.0\n * @property name This will be `'ArgumentError'` and can be used to distinguish the type of error when any error gets thrown\n */\nexport class ArgumentError<T = unknown> extends UserError {\n\tpublic readonly argument: IArgument<T>;\n\tpublic readonly parameter: string;\n\n\tpublic constructor(options: ArgumentError.Options<T>) {\n\t\tsuper({ ...options, identifier: options.identifier ?? options.argument.name });\n\t\tthis.argument = options.argument;\n\t\tthis.parameter = options.parameter;\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/class-literal-property-style\n\tpublic override get name(): string {\n\t\treturn 'ArgumentError';\n\t}\n}\n\nexport namespace ArgumentError {\n\t/**\n\t * The options for {@link ArgumentError}.\n\t * @since 1.0.0\n\t */\n\texport interface Options<T> extends Omit<UserError.Options, 'identifier'> {\n\t\t/**\n\t\t * The argument that caused the error.\n\t\t * @since 1.0.0\n\t\t */\n\t\targument: IArgument<T>;\n\n\t\t/**\n\t\t * The parameter that failed to be parsed.\n\t\t * @since 1.0.0\n\t\t */\n\t\tparameter: string;\n\n\t\t/**\n\t\t * The identifier.\n\t\t * @since 1.0.0\n\t\t * @default argument.name\n\t\t */\n\t\tidentifier?: string;\n\t}\n}\n"]}