forked from intercom/intercom-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandleNonStatusCodeError.ts
More file actions
37 lines (35 loc) · 1.17 KB
/
handleNonStatusCodeError.ts
File metadata and controls
37 lines (35 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// This file was auto-generated by Fern from our API Definition.
import type * as core from "../core/index.js";
import * as errors from "./index.js";
export function handleNonStatusCodeError(
error: core.Fetcher.Error,
rawResponse: core.RawResponse,
method: string,
path: string,
): never {
switch (error.reason) {
case "non-json":
throw new errors.IntercomError({
statusCode: error.statusCode,
body: error.rawBody,
rawResponse: rawResponse,
});
case "body-is-null":
throw new errors.IntercomError({
statusCode: error.statusCode,
rawResponse: rawResponse,
});
case "timeout":
throw new errors.IntercomTimeoutError(`Timeout exceeded when calling ${method} ${path}.`);
case "unknown":
throw new errors.IntercomError({
message: error.errorMessage,
rawResponse: rawResponse,
});
default:
throw new errors.IntercomError({
message: "Unknown error",
rawResponse: rawResponse,
});
}
}