1 |
|
2 |
|
3 | import type { IncomingHttpHeaders } from 'node:http';
|
4 | import type { AxiosResponse } from 'axios';
|
5 | import type { WebAPICallResult } from './WebClient';
|
6 |
|
7 |
|
8 |
|
9 | export interface CodedError extends NodeJS.ErrnoException {
|
10 | code: ErrorCode;
|
11 | }
|
12 |
|
13 |
|
14 |
|
15 | export declare enum ErrorCode {
|
16 | RequestError = "slack_webapi_request_error",
|
17 | HTTPError = "slack_webapi_http_error",
|
18 | PlatformError = "slack_webapi_platform_error",
|
19 | RateLimitedError = "slack_webapi_rate_limited_error",
|
20 | FileUploadInvalidArgumentsError = "slack_webapi_file_upload_invalid_args_error",
|
21 | FileUploadReadFileDataError = "slack_webapi_file_upload_read_file_data_error"
|
22 | }
|
23 | export type WebAPICallError = WebAPIPlatformError | WebAPIRequestError | WebAPIHTTPError | WebAPIRateLimitedError;
|
24 | export type WebAPIFilesUploadError = WebAPIFileUploadInvalidArgumentsError;
|
25 | export interface WebAPIFileUploadInvalidArgumentsError extends CodedError {
|
26 | code: ErrorCode.FileUploadInvalidArgumentsError;
|
27 | data: WebAPICallResult & {
|
28 | error: string;
|
29 | };
|
30 | }
|
31 | export interface WebAPIPlatformError extends CodedError {
|
32 | code: ErrorCode.PlatformError;
|
33 | data: WebAPICallResult & {
|
34 | error: string;
|
35 | };
|
36 | }
|
37 | export interface WebAPIRequestError extends CodedError {
|
38 | code: ErrorCode.RequestError;
|
39 | original: Error;
|
40 | }
|
41 | export interface WebAPIHTTPError extends CodedError {
|
42 | code: ErrorCode.HTTPError;
|
43 | statusCode: number;
|
44 | statusMessage: string;
|
45 | headers: IncomingHttpHeaders;
|
46 | body?: any;
|
47 | }
|
48 | export interface WebAPIRateLimitedError extends CodedError {
|
49 | code: ErrorCode.RateLimitedError;
|
50 | retryAfter: number;
|
51 | }
|
52 |
|
53 |
|
54 |
|
55 | export declare function errorWithCode(error: Error, code: ErrorCode): CodedError;
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 | export declare function requestErrorWithOriginal(original: Error, attachOriginal: boolean): WebAPIRequestError;
|
62 |
|
63 |
|
64 |
|
65 |
|
66 | export declare function httpErrorFromResponse(response: AxiosResponse): WebAPIHTTPError;
|
67 |
|
68 |
|
69 |
|
70 |
|
71 | export declare function platformErrorFromResult(result: WebAPICallResult & {
|
72 | error: string;
|
73 | }): WebAPIPlatformError;
|
74 |
|
75 |
|
76 |
|
77 |
|
78 | export declare function rateLimitedErrorWithDelay(retrySec: number): WebAPIRateLimitedError;
|
79 |
|
\ | No newline at end of file |