This repository has been archived by the owner on Jan 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Errors): show data sent when an error occurs (#72)
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
- Loading branch information
1 parent
3b53910
commit 3e2edc8
Showing
6 changed files
with
68 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,30 @@ | ||
import type { InternalRequest } from '../RequestManager'; | ||
import type { RequestBody } from './DiscordAPIError'; | ||
|
||
/** | ||
* Represents a HTTP error | ||
*/ | ||
export class HTTPError extends Error { | ||
public requestBody: RequestBody; | ||
|
||
/** | ||
* @param message The error message | ||
* @param name The name of the error | ||
* @param status The status code of the response | ||
* @param method The method of the request that erred | ||
* @param url The url of the request that erred | ||
* @param bodyData The unparsed data for the request that errored | ||
*/ | ||
public constructor( | ||
message: string, | ||
public name: string, | ||
public status: number, | ||
public method: string, | ||
public url: string, | ||
bodyData: Pick<InternalRequest, 'attachments' | 'body'>, | ||
) { | ||
super(message); | ||
|
||
this.requestBody = { attachments: bodyData.attachments, json: bodyData.body }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
import type { RequestInit } from 'node-fetch'; | ||
import type { RouteData } from '../RequestManager'; | ||
import type { InternalRequest, RouteData } from '../RequestManager'; | ||
|
||
export interface IHandler { | ||
queueRequest(routeId: RouteData, url: string, options: RequestInit): Promise<unknown>; | ||
queueRequest( | ||
routeId: RouteData, | ||
url: string, | ||
options: RequestInit, | ||
bodyData: Pick<InternalRequest, 'attachments' | 'body'>, | ||
): Promise<unknown>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters