UNPKG

@sapphire/framework

Version:

Discord bot framework built for advanced and amazing bots.

1 lines 1.52 kB
{"version":3,"file":"PreconditionError.mjs","names":[],"sources":["../../../../src/lib/errors/PreconditionError.ts"],"sourcesContent":["import type { Precondition } from '../structures/Precondition';\nimport { UserError } from './UserError';\n\n/**\n * Errors thrown by preconditions\n * @property name This will be `'PreconditionError'` and can be used to distinguish the type of error when any error gets thrown\n */\nexport class PreconditionError extends UserError {\n\tpublic readonly precondition: Precondition;\n\n\tpublic constructor(options: PreconditionError.Options) {\n\t\tsuper({ ...options, identifier: options.identifier ?? options.precondition.name });\n\t\tthis.precondition = options.precondition;\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/class-literal-property-style\n\tpublic override get name(): string {\n\t\treturn 'PreconditionError';\n\t}\n}\n\nexport namespace PreconditionError {\n\t/**\n\t * The options for {@link PreconditionError}.\n\t * @since 1.0.0\n\t */\n\texport interface Options extends Omit<UserError.Options, 'identifier'> {\n\t\t/**\n\t\t * The precondition that caused the error.\n\t\t * @since 1.0.0\n\t\t */\n\t\tprecondition: Precondition;\n\n\t\t/**\n\t\t * The identifier.\n\t\t * @since 1.0.0\n\t\t * @default precondition.name\n\t\t */\n\t\tidentifier?: string;\n\t}\n}\n"],"mappings":";;;;;;;AAOA,IAAa,oBAAb,cAAuC,UAAU;CAGhD,AAAO,YAAY,SAAoC;AACtD,QAAM;GAAE,GAAG;GAAS,YAAY,QAAQ,cAAc,QAAQ,aAAa;GAAM,CAAC;AAClF,OAAK,eAAe,QAAQ;;CAI7B,IAAoB,OAAe;AAClC,SAAO"}