Skip to content

Commit

Permalink
feat: add common JSON error types (#568)
Browse files Browse the repository at this point in the history
  • Loading branch information
promise committed Aug 19, 2022
1 parent ef8241f commit 956f289
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
20 changes: 20 additions & 0 deletions deno/payloads/common.ts
Expand Up @@ -58,3 +58,23 @@ export const PermissionFlagsBits = {
Object.freeze(PermissionFlagsBits);

export type LocalizationMap = Partial<Record<LocaleString, string | null>>;

/**
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#json
*/
export interface RESTError {
code: number;
message: string;
errors?: RESTErrorData;
}

export interface RESTErrorFieldInformation {
code: string;
message: string;
}

export interface RESTErrorGroupWrapper {
_errors: RESTErrorData[];
}

export type RESTErrorData = RESTErrorGroupWrapper | RESTErrorFieldInformation | { [k: string]: RESTErrorData } | string;
20 changes: 20 additions & 0 deletions payloads/common.ts
Expand Up @@ -58,3 +58,23 @@ export const PermissionFlagsBits = {
Object.freeze(PermissionFlagsBits);

export type LocalizationMap = Partial<Record<LocaleString, string | null>>;

/**
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#json
*/
export interface RESTError {
code: number;
message: string;
errors?: RESTErrorData;
}

export interface RESTErrorFieldInformation {
code: string;
message: string;
}

export interface RESTErrorGroupWrapper {
_errors: RESTErrorData[];
}

export type RESTErrorData = RESTErrorGroupWrapper | RESTErrorFieldInformation | { [k: string]: RESTErrorData } | string;

0 comments on commit 956f289

Please sign in to comment.