-
Notifications
You must be signed in to change notification settings - Fork 97
/
WebflowError.ts
45 lines (38 loc) · 1.05 KB
/
WebflowError.ts
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
38
39
40
41
42
43
44
45
/**
* This file was auto-generated by Fern from our API Definition.
*/
export class WebflowError extends Error {
readonly statusCode?: number;
readonly body?: unknown;
constructor({ message, statusCode, body }: { message?: string; statusCode?: number; body?: unknown }) {
super(buildMessage({ message, statusCode, body }));
Object.setPrototypeOf(this, WebflowError.prototype);
if (statusCode != null) {
this.statusCode = statusCode;
}
if (body !== undefined) {
this.body = body;
}
}
}
function buildMessage({
message,
statusCode,
body,
}: {
message: string | undefined;
statusCode: number | undefined;
body: unknown | undefined;
}): string {
let lines: string[] = [];
if (message != null) {
lines.push(message);
}
if (statusCode != null) {
lines.push(`Status code: ${statusCode.toString()}`);
}
if (body != null) {
lines.push(`Body: ${JSON.stringify(body, undefined, 2)}`);
}
return lines.join("\n");
}