@@ -126,52 +126,43 @@ type QueryParams = Record<string, string | string[] | Date | Date[] | boolean |
126126type QueryOptions = Record < string , { explode ?: boolean ; delimiter ?: "," | " " | "|" , format ?: "date" } > ;
127127
128128export class HttpError extends Error {
129- readonly response : Response ;
130- readonly body : any ;
131-
132- constructor ( response : Response , body ?: any ) {
133- super ( response . statusText ) ;
134- this . response = response ;
135- this . body = body ;
136- Object . setPrototypeOf ( this , HttpError . prototype ) ;
129+ constructor ( public readonly response : Response , public readonly body ?: any ) {
130+ super ( body ?. message || response . statusText || response . status ) ;
131+ this . name = new . target . name ;
132+ Object . setPrototypeOf ( this , new . target . prototype ) ;
137133 }
138134}
139135
140136export class ServerError extends HttpError {
141137 constructor ( response : Response , body : any ) {
142138 super ( response , body ) ;
143- Object . setPrototypeOf ( this , ServerError . prototype ) ;
144139 }
145140}
146141
147142export class RequestError extends HttpError {
148143 constructor ( response : Response , body : any ) {
149144 super ( response , body ) ;
150- Object . setPrototypeOf ( this , RequestError . prototype ) ;
151145 }
152146}
153147
154148export class LoggedOutError extends RequestError {
155149 constructor ( response : Response , body : any ) {
156150 super ( response , body ) ;
157- Object . setPrototypeOf ( this , LoggedOutError . prototype ) ;
158151 }
159152}
160153
161154export class NotFoundError extends RequestError {
162155 constructor ( response : Response , body : any ) {
163156 super ( response , body ) ;
164- Object . setPrototypeOf ( this , NotFoundError . prototype ) ;
165157 }
166158}
167159
168160export class RedirectedError extends HttpError {
169161 constructor ( response : Response ) {
170162 super ( response ) ;
171- Object . setPrototypeOf ( this , RedirectedError . prototype ) ;
172163 }
173164}
174165
175166export interface SecurityScheme {
176167 headers ( ) : Record < string , string > ;
177- }
168+ }
0 commit comments