-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrormodel.ts
More file actions
122 lines (114 loc) · 3.45 KB
/
errormodel.ts
File metadata and controls
122 lines (114 loc) · 3.45 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod/v3";
import { remap as remap$ } from "../../lib/primitives.js";
import * as components from "../components/index.js";
import { SteamSetsError } from "./steamsetserror.js";
export type ErrorModelData = {
/**
* A URL to the JSON Schema for this object.
*/
dollarSchema?: string | undefined;
/**
* A human-readable explanation specific to this occurrence of the problem.
*/
detail?: string | undefined;
/**
* Optional list of individual error details
*/
errors?: Array<components.ErrorDetail> | null | undefined;
/**
* A URI reference that identifies the specific occurrence of the problem.
*/
instance?: string | undefined;
/**
* HTTP status code
*/
status?: number | undefined;
/**
* A short, human-readable summary of the problem type. This value should not change between occurrences of the error.
*/
title?: string | undefined;
/**
* A URI reference to human-readable documentation for the error.
*/
type?: string | undefined;
};
export class ErrorModel extends SteamSetsError {
/**
* A URL to the JSON Schema for this object.
*/
dollarSchema?: string | undefined;
/**
* A human-readable explanation specific to this occurrence of the problem.
*/
detail?: string | undefined;
/**
* Optional list of individual error details
*/
errors?: Array<components.ErrorDetail> | null | undefined;
/**
* A URI reference that identifies the specific occurrence of the problem.
*/
instance?: string | undefined;
/**
* HTTP status code
*/
status?: number | undefined;
/**
* A short, human-readable summary of the problem type. This value should not change between occurrences of the error.
*/
title?: string | undefined;
/**
* A URI reference to human-readable documentation for the error.
*/
type?: string | undefined;
/** The original data that was passed to this error instance. */
data$: ErrorModelData;
constructor(
err: ErrorModelData,
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.dollarSchema != null) this.dollarSchema = err.dollarSchema;
if (err.detail != null) this.detail = err.detail;
if (err.errors != null) this.errors = err.errors;
if (err.instance != null) this.instance = err.instance;
if (err.status != null) this.status = err.status;
if (err.title != null) this.title = err.title;
if (err.type != null) this.type = err.type;
this.name = "ErrorModel";
}
}
/** @internal */
export const ErrorModel$inboundSchema: z.ZodType<
ErrorModel,
z.ZodTypeDef,
unknown
> = z.object({
$schema: z.string().optional(),
detail: z.string().optional(),
errors: z.nullable(z.array(components.ErrorDetail$inboundSchema)).optional(),
instance: z.string().optional(),
status: z.number().int().optional(),
title: z.string().optional(),
type: z.string().default("about:blank"),
request$: z.instanceof(Request),
response$: z.instanceof(Response),
body$: z.string(),
})
.transform((v) => {
const remapped = remap$(v, {
"$schema": "dollarSchema",
});
return new ErrorModel(remapped, {
request: v.request$,
response: v.response$,
body: v.body$,
});
});