-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathhttpapidecodeerror.ts
More file actions
81 lines (72 loc) · 1.85 KB
/
httpapidecodeerror.ts
File metadata and controls
81 lines (72 loc) · 1.85 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod/v3";
import * as types from "../types/primitives.js";
import {
Issue,
Issue$inboundSchema,
Issue$Outbound,
Issue$outboundSchema,
} from "./issue.js";
import { VercelError } from "./vercelerror.js";
/**
* The request did not match the expected schema
*/
export type HttpApiDecodeErrorData = {
issues: Array<Issue>;
message: string;
};
/**
* The request did not match the expected schema
*/
export class HttpApiDecodeError extends VercelError {
issues: Array<Issue>;
/** The original data that was passed to this error instance. */
data$: HttpApiDecodeErrorData;
constructor(
err: HttpApiDecodeErrorData,
httpMeta: { response: Response; request: Request; body: string },
) {
const message = err.message || `API error occurred: ${JSON.stringify(err)}`;
super(message, httpMeta);
this.data$ = err;
this.issues = err.issues;
this.name = "HttpApiDecodeError";
}
}
/** @internal */
export const HttpApiDecodeError$inboundSchema: z.ZodType<
HttpApiDecodeError,
z.ZodTypeDef,
unknown
> = z.object({
issues: z.array(Issue$inboundSchema),
message: types.string(),
request$: z.instanceof(Request),
response$: z.instanceof(Response),
body$: z.string(),
})
.transform((v) => {
return new HttpApiDecodeError(v, {
request: v.request$,
response: v.response$,
body: v.body$,
});
});
/** @internal */
export type HttpApiDecodeError$Outbound = {
issues: Array<Issue$Outbound>;
message: string;
};
/** @internal */
export const HttpApiDecodeError$outboundSchema: z.ZodType<
HttpApiDecodeError$Outbound,
z.ZodTypeDef,
HttpApiDecodeError
> = z.instanceof(HttpApiDecodeError)
.transform(v => v.data$)
.pipe(z.object({
issues: z.array(Issue$outboundSchema),
message: z.string(),
}));