@@ -82,6 +82,29 @@ export function deserializeSuccess<TObject>(response: Response): TObject {
82
82
}
83
83
}
84
84
85
+ const httpMessages : Record < number , string > = {
86
+ 400 : 'Bad Request' ,
87
+ 401 : 'Unauthorized' ,
88
+ 402 : 'Payment Required' ,
89
+ 403 : 'Forbidden' ,
90
+ 404 : 'Not Found' ,
91
+ 405 : 'Method Not Allowed' ,
92
+ 406 : 'Not Acceptable' ,
93
+ 407 : 'Proxy Authentication Required' ,
94
+ 408 : 'Request Timeout' ,
95
+ 409 : 'Conflict' ,
96
+ 410 : 'Gone' ,
97
+ 411 : 'Length Required' ,
98
+ 412 : 'Precondition Required' ,
99
+ 413 : 'Request Entry Too Large' ,
100
+ 414 : 'Request-URI Too Long' ,
101
+ 415 : 'Unsupported Media Type' ,
102
+ 416 : 'Requested Range Not Satisfiable' ,
103
+ 417 : 'Expectation Failed' ,
104
+ 418 : "I'm a teapot" ,
105
+ 429 : 'Too Many Requests' ,
106
+ } ;
107
+
85
108
export function deserializeFailure ( { content, status } : Response , stackFrame : StackFrame [ ] ) : Error {
86
109
try {
87
110
const parsed = JSON . parse ( content ) ;
@@ -92,5 +115,5 @@ export function deserializeFailure({ content, status }: Response, stackFrame: St
92
115
} catch {
93
116
// ..
94
117
}
95
- return new ApiError ( content , status , stackFrame ) ;
118
+ return new ApiError ( status in httpMessages ? httpMessages [ status ] : content , status , stackFrame ) ;
96
119
}
0 commit comments