-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathunauthorizederror.ts
More file actions
53 lines (46 loc) · 1.46 KB
/
Copy pathunauthorizederror.ts
File metadata and controls
53 lines (46 loc) · 1.46 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
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod/v4";
import * as types from "../../types/primitives.js";
import * as shared from "../shared/index.js";
import { PlexAPIError } from "./plexapierror.js";
export type UnauthorizedErrorData = {
errors?: Array<shared.UnauthorizedError> | undefined;
};
export class UnauthorizedError extends PlexAPIError {
errors?: Array<shared.UnauthorizedError> | undefined;
/** The original data that was passed to this error instance. */
data$: UnauthorizedErrorData;
constructor(
err: UnauthorizedErrorData,
httpMeta: { response: Response; request: Request; body: string },
) {
const message = "message" in err && typeof err.message === "string"
? err.message
: `API error occurred: ${JSON.stringify(err)}`;
super(message, httpMeta);
this.data$ = err;
if (err.errors != null) this.errors = err.errors;
this.name = "UnauthorizedError";
}
}
/** @internal */
export const UnauthorizedError$inboundSchema: z.ZodType<
UnauthorizedError,
unknown
> = z.object({
errors: types.optional(
z.array(z.lazy(() => shared.UnauthorizedError$inboundSchema)),
),
request$: z.custom<Request>(x => x instanceof Request),
response$: z.custom<Response>(x => x instanceof Response),
body$: z.string(),
})
.transform((v) => {
return new UnauthorizedError(v, {
request: v.request$,
response: v.response$,
body: v.body$,
});
});