ratelimitederrorrep.ts•2.31 kB
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod";
import { LaunchDarklyError } from "./launchdarklyerror.js";
export type RateLimitedErrorRepData = {
/**
* Specific error code encountered
*/
code: string;
/**
* Description of the error
*/
message: string;
};
export class RateLimitedErrorRep extends LaunchDarklyError {
/**
* Specific error code encountered
*/
code: string;
/** The original data that was passed to this error instance. */
data$: RateLimitedErrorRepData;
constructor(
err: RateLimitedErrorRepData,
httpMeta: { response: Response; request: Request; body: string },
) {
const message = err.message || `API error occurred: ${JSON.stringify(err)}`;
super(message, httpMeta);
this.data$ = err;
this.code = err.code;
this.name = "RateLimitedErrorRep";
}
}
/** @internal */
export const RateLimitedErrorRep$inboundSchema: z.ZodType<
RateLimitedErrorRep,
z.ZodTypeDef,
unknown
> = z.object({
code: z.string(),
message: z.string(),
request$: z.instanceof(Request),
response$: z.instanceof(Response),
body$: z.string(),
})
.transform((v) => {
return new RateLimitedErrorRep(v, {
request: v.request$,
response: v.response$,
body: v.body$,
});
});
/** @internal */
export type RateLimitedErrorRep$Outbound = {
code: string;
message: string;
};
/** @internal */
export const RateLimitedErrorRep$outboundSchema: z.ZodType<
RateLimitedErrorRep$Outbound,
z.ZodTypeDef,
RateLimitedErrorRep
> = z.instanceof(RateLimitedErrorRep)
.transform(v => v.data$)
.pipe(z.object({
code: z.string(),
message: z.string(),
}));
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace RateLimitedErrorRep$ {
/** @deprecated use `RateLimitedErrorRep$inboundSchema` instead. */
export const inboundSchema = RateLimitedErrorRep$inboundSchema;
/** @deprecated use `RateLimitedErrorRep$outboundSchema` instead. */
export const outboundSchema = RateLimitedErrorRep$outboundSchema;
/** @deprecated use `RateLimitedErrorRep$Outbound` instead. */
export type Outbound = RateLimitedErrorRep$Outbound;
}