Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove usage of mixin on error classes #10128

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3915,23 +3915,23 @@ export enum DiscordjsErrorCodes {
EntitlementCreateInvalidOwner = 'EntitlementCreateInvalidOwner',
}

/** @internal */
export interface DiscordjsErrorFields<Name extends string> {
readonly name: `${Name} [${DiscordjsErrorCodes}]`;
get code(): DiscordjsErrorCodes;
export class DiscordjsError extends Error {
private constructor(code: DiscordjsErrorCodes, ...args: unknown[]);
public readonly code: DiscordjsErrorCodes;
public get name(): `Error [${DiscordjsErrorCodes}]`;
}

/** @internal */
export function DiscordjsErrorMixin<Entity, Name extends string>(
Base: Constructable<Entity>,
name: Name,
): Constructable<Entity & DiscordjsErrorFields<Name>>;

export class DiscordjsError extends DiscordjsErrorMixin(Error, 'Error') {}

export class DiscordjsTypeError extends DiscordjsErrorMixin(TypeError, 'TypeError') {}
export class DiscordjsTypeError extends TypeError {
private constructor(code: DiscordjsErrorCodes, ...args: unknown[]);
public readonly code: DiscordjsErrorCodes;
public get name(): `TypeError [${DiscordjsErrorCodes}]`;
}

export class DiscordjsRangeError extends DiscordjsErrorMixin(RangeError, 'RangeError') {}
export class DiscordjsRangeError extends RangeError {
private constructor(code: DiscordjsErrorCodes, ...args: unknown[]);
public readonly code: DiscordjsErrorCodes;
public get name(): `RangeError [${DiscordjsErrorCodes}]`;
}

//#endregion

Expand Down
Loading