11'use strict'
22
3+ const kUndiciError = Symbol . for ( 'undici.error.UND_ERR' )
34class UndiciError extends Error {
45constructor ( message ) {
56super ( message )
67this . name = 'UndiciError'
78this . code = 'UND_ERR'
89}
10+
11+ static [ Symbol . hasInstance ] ( instance ) {
12+ return instance && instance [ kUndiciError ] === true
13+ }
14+
15+ [ kUndiciError ] = true
916}
1017
18+ const kConnectTimeoutError = Symbol . for ( 'undici.error.UND_ERR_CONNECT_TIMEOUT' )
1119class ConnectTimeoutError extends UndiciError {
1220constructor ( message ) {
1321super ( message )
1422this . name = 'ConnectTimeoutError'
1523this . message = message || 'Connect Timeout Error'
1624this . code = 'UND_ERR_CONNECT_TIMEOUT'
1725}
26+
27+ static [ Symbol . hasInstance ] ( instance ) {
28+ return instance && instance [ kConnectTimeoutError ] === true
29+ }
30+
31+ [ kConnectTimeoutError ] = true
1832}
1933
34+ const kHeadersTimeoutError = Symbol . for ( 'undici.error.UND_ERR_HEADERS_TIMEOUT' )
2035class HeadersTimeoutError extends UndiciError {
2136constructor ( message ) {
2237super ( message )
2338this . name = 'HeadersTimeoutError'
2439this . message = message || 'Headers Timeout Error'
2540this . code = 'UND_ERR_HEADERS_TIMEOUT'
2641}
42+
43+ static [ Symbol . hasInstance ] ( instance ) {
44+ return instance && instance [ kHeadersTimeoutError ] === true
45+ }
46+
47+ [ kHeadersTimeoutError ] = true
2748}
2849
50+ const kHeadersOverflowError = Symbol . for ( 'undici.error.UND_ERR_HEADERS_OVERFLOW' )
2951class HeadersOverflowError extends UndiciError {
3052constructor ( message ) {
3153super ( message )
3254this . name = 'HeadersOverflowError'
3355this . message = message || 'Headers Overflow Error'
3456this . code = 'UND_ERR_HEADERS_OVERFLOW'
3557}
58+
59+ static [ Symbol . hasInstance ] ( instance ) {
60+ return instance && instance [ kHeadersOverflowError ] === true
61+ }
62+
63+ [ kHeadersOverflowError ] = true
3664}
3765
66+ const kBodyTimeoutError = Symbol . for ( 'undici.error.UND_ERR_BODY_TIMEOUT' )
3867class BodyTimeoutError extends UndiciError {
3968constructor ( message ) {
4069super ( message )
4170this . name = 'BodyTimeoutError'
4271this . message = message || 'Body Timeout Error'
4372this . code = 'UND_ERR_BODY_TIMEOUT'
4473}
74+
75+ static [ Symbol . hasInstance ] ( instance ) {
76+ return instance && instance [ kBodyTimeoutError ] === true
77+ }
78+
79+ [ kBodyTimeoutError ] = true
4580}
4681
82+ const kResponseStatusCodeError = Symbol . for ( 'undici.error.UND_ERR_RESPONSE_STATUS_CODE' )
4783class ResponseStatusCodeError extends UndiciError {
4884constructor ( message , statusCode , headers , body ) {
4985super ( message )
@@ -55,88 +91,159 @@ class ResponseStatusCodeError extends UndiciError {
5591this . statusCode = statusCode
5692this . headers = headers
5793}
94+
95+ static [ Symbol . hasInstance ] ( instance ) {
96+ return instance && instance [ kResponseStatusCodeError ] === true
97+ }
98+
99+ [ kResponseStatusCodeError ] = true
58100}
59101
102+ const kInvalidArgumentError = Symbol . for ( 'undici.error.UND_ERR_INVALID_ARG' )
60103class InvalidArgumentError extends UndiciError {
61104constructor ( message ) {
62105super ( message )
63106this . name = 'InvalidArgumentError'
64107this . message = message || 'Invalid Argument Error'
65108this . code = 'UND_ERR_INVALID_ARG'
66109}
110+
111+ static [ Symbol . hasInstance ] ( instance ) {
112+ return instance && instance [ kInvalidArgumentError ] === true
113+ }
114+
115+ [ kInvalidArgumentError ] = true
67116}
68117
118+ const kInvalidReturnValueError = Symbol . for ( 'undici.error.UND_ERR_INVALID_RETURN_VALUE' )
69119class InvalidReturnValueError extends UndiciError {
70120constructor ( message ) {
71121super ( message )
72122this . name = 'InvalidReturnValueError'
73123this . message = message || 'Invalid Return Value Error'
74124this . code = 'UND_ERR_INVALID_RETURN_VALUE'
75125}
126+
127+ static [ Symbol . hasInstance ] ( instance ) {
128+ return instance && instance [ kInvalidReturnValueError ] === true
129+ }
130+
131+ [ kInvalidReturnValueError ] = true
76132}
77133
134+ const kAbortError = Symbol . for ( 'undici.error.UND_ERR_ABORT' )
78135class AbortError extends UndiciError {
79136constructor ( message ) {
80137super ( message )
81138this . name = 'AbortError'
82139this . message = message || 'The operation was aborted'
140+ this . code = 'UND_ERR_ABORT'
141+ }
142+
143+ static [ Symbol . hasInstance ] ( instance ) {
144+ return instance && instance [ kAbortError ] === true
83145}
146+
147+ [ kAbortError ] = true
84148}
85149
150+ const kRequestAbortedError = Symbol . for ( 'undici.error.UND_ERR_ABORTED' )
86151class RequestAbortedError extends AbortError {
87152constructor ( message ) {
88153super ( message )
89154this . name = 'AbortError'
90155this . message = message || 'Request aborted'
91156this . code = 'UND_ERR_ABORTED'
92157}
158+
159+ static [ Symbol . hasInstance ] ( instance ) {
160+ return instance && instance [ kRequestAbortedError ] === true
161+ }
162+
163+ [ kRequestAbortedError ] = true
93164}
94165
166+ const kInformationalError = Symbol . for ( 'undici.error.UND_ERR_INFO' )
95167class InformationalError extends UndiciError {
96168constructor ( message ) {
97169super ( message )
98170this . name = 'InformationalError'
99171this . message = message || 'Request information'
100172this . code = 'UND_ERR_INFO'
101173}
174+
175+ static [ Symbol . hasInstance ] ( instance ) {
176+ return instance && instance [ kInformationalError ] === true
177+ }
178+
179+ [ kInformationalError ] = true
102180}
103181
182+ const kRequestContentLengthMismatchError = Symbol . for ( 'undici.error.UND_ERR_REQ_CONTENT_LENGTH_MISMATCH' )
104183class RequestContentLengthMismatchError extends UndiciError {
105184constructor ( message ) {
106185super ( message )
107186this . name = 'RequestContentLengthMismatchError'
108187this . message = message || 'Request body length does not match content-length header'
109188this . code = 'UND_ERR_REQ_CONTENT_LENGTH_MISMATCH'
110189}
190+
191+ static [ Symbol . hasInstance ] ( instance ) {
192+ return instance && instance [ kRequestContentLengthMismatchError ] === true
193+ }
194+
195+ [ kRequestContentLengthMismatchError ] = true
111196}
112197
198+ const kResponseContentLengthMismatchError = Symbol . for ( 'undici.error.UND_ERR_RES_CONTENT_LENGTH_MISMATCH' )
113199class ResponseContentLengthMismatchError extends UndiciError {
114200constructor ( message ) {
115201super ( message )
116202this . name = 'ResponseContentLengthMismatchError'
117203this . message = message || 'Response body length does not match content-length header'
118204this . code = 'UND_ERR_RES_CONTENT_LENGTH_MISMATCH'
119205}
206+
207+ static [ Symbol . hasInstance ] ( instance ) {
208+ return instance && instance [ kResponseContentLengthMismatchError ] === true
209+ }
210+
211+ [ kResponseContentLengthMismatchError ] = true
120212}
121213
214+ const kClientDestroyedError = Symbol . for ( 'undici.error.UND_ERR_DESTROYED' )
122215class ClientDestroyedError extends UndiciError {
123216constructor ( message ) {
124217super ( message )
125218this . name = 'ClientDestroyedError'
126219this . message = message || 'The client is destroyed'
127220this . code = 'UND_ERR_DESTROYED'
128221}
222+
223+ static [ Symbol . hasInstance ] ( instance ) {
224+ return instance && instance [ kClientDestroyedError ] === true
225+ }
226+
227+ [ kClientDestroyedError ] = true
129228}
130229
230+ const kClientClosedError = Symbol . for ( 'undici.error.UND_ERR_CLOSED' )
131231class ClientClosedError extends UndiciError {
132232constructor ( message ) {
133233super ( message )
134234this . name = 'ClientClosedError'
135235this . message = message || 'The client is closed'
136236this . code = 'UND_ERR_CLOSED'
137237}
238+
239+ static [ Symbol . hasInstance ] ( instance ) {
240+ return instance && instance [ kClientClosedError ] === true
241+ }
242+
243+ [ kClientClosedError ] = true
138244}
139245
246+ const kSocketError = Symbol . for ( 'undici.error.UND_ERR_SOCKET' )
140247class SocketError extends UndiciError {
141248constructor ( message , socket ) {
142249super ( message )
@@ -145,44 +252,79 @@ class SocketError extends UndiciError {
145252this . code = 'UND_ERR_SOCKET'
146253this . socket = socket
147254}
255+
256+ static [ Symbol . hasInstance ] ( instance ) {
257+ return instance && instance [ kSocketError ] === true
258+ }
259+
260+ [ kSocketError ] = true
148261}
149262
263+ const kNotSupportedError = Symbol . for ( 'undici.error.UND_ERR_NOT_SUPPORTED' )
150264class NotSupportedError extends UndiciError {
151265constructor ( message ) {
152266super ( message )
153267this . name = 'NotSupportedError'
154268this . message = message || 'Not supported error'
155269this . code = 'UND_ERR_NOT_SUPPORTED'
156270}
271+
272+ static [ Symbol . hasInstance ] ( instance ) {
273+ return instance && instance [ kNotSupportedError ] === true
274+ }
275+
276+ [ kNotSupportedError ] = true
157277}
158278
279+ const kBalancedPoolMissingUpstreamError = Symbol . for ( 'undici.error.UND_ERR_BPL_MISSING_UPSTREAM' )
159280class BalancedPoolMissingUpstreamError extends UndiciError {
160281constructor ( message ) {
161282super ( message )
162283this . name = 'MissingUpstreamError'
163284this . message = message || 'No upstream has been added to the BalancedPool'
164285this . code = 'UND_ERR_BPL_MISSING_UPSTREAM'
165286}
287+
288+ static [ Symbol . hasInstance ] ( instance ) {
289+ return instance && instance [ kBalancedPoolMissingUpstreamError ] === true
290+ }
291+
292+ [ kBalancedPoolMissingUpstreamError ] = true
166293}
167294
295+ const kHTTPParserError = Symbol . for ( 'undici.error.UND_ERR_HTTP_PARSER' )
168296class HTTPParserError extends Error {
169297constructor ( message , code , data ) {
170298super ( message )
171299this . name = 'HTTPParserError'
172300this . code = code ? `HPE_${ code } ` : undefined
173301this . data = data ? data . toString ( ) : undefined
174302}
303+
304+ static [ Symbol . hasInstance ] ( instance ) {
305+ return instance && instance [ kHTTPParserError ] === true
306+ }
307+
308+ [ kHTTPParserError ] = true
175309}
176310
311+ const kResponseExceededMaxSizeError = Symbol . for ( 'undici.error.UND_ERR_RES_EXCEEDED_MAX_SIZE' )
177312class ResponseExceededMaxSizeError extends UndiciError {
178313constructor ( message ) {
179314super ( message )
180315this . name = 'ResponseExceededMaxSizeError'
181316this . message = message || 'Response content exceeded max size'
182317this . code = 'UND_ERR_RES_EXCEEDED_MAX_SIZE'
183318}
319+
320+ static [ Symbol . hasInstance ] ( instance ) {
321+ return instance && instance [ kResponseExceededMaxSizeError ] === true
322+ }
323+
324+ [ kResponseExceededMaxSizeError ] = true
184325}
185326
327+ const kRequestRetryError = Symbol . for ( 'undici.error.UND_ERR_REQ_RETRY' )
186328class RequestRetryError extends UndiciError {
187329constructor ( message , code , { headers, data } ) {
188330super ( message )
@@ -193,8 +335,15 @@ class RequestRetryError extends UndiciError {
193335this . data = data
194336this . headers = headers
195337}
338+
339+ static [ Symbol . hasInstance ] ( instance ) {
340+ return instance && instance [ kRequestRetryError ] === true
341+ }
342+
343+ [ kRequestRetryError ] = true
196344}
197345
346+ const kResponseError = Symbol . for ( 'undici.error.UND_ERR_RESPONSE' )
198347class ResponseError extends UndiciError {
199348constructor ( message , code , { headers, data } ) {
200349super ( message )
@@ -205,8 +354,15 @@ class ResponseError extends UndiciError {
205354this . data = data
206355this . headers = headers
207356}
357+
358+ static [ Symbol . hasInstance ] ( instance ) {
359+ return instance && instance [ kResponseError ] === true
360+ }
361+
362+ [ kResponseError ] = true
208363}
209364
365+ const kSecureProxyConnectionError = Symbol . for ( 'undici.error.UND_ERR_PRX_TLS' )
210366class SecureProxyConnectionError extends UndiciError {
211367constructor ( cause , message , options ) {
212368super ( message , { cause, ...( options ?? { } ) } )
@@ -215,6 +371,12 @@ class SecureProxyConnectionError extends UndiciError {
215371this . code = 'UND_ERR_PRX_TLS'
216372this . cause = cause
217373}
374+
375+ static [ Symbol . hasInstance ] ( instance ) {
376+ return instance && instance [ kSecureProxyConnectionError ] === true
377+ }
378+
379+ [ kSecureProxyConnectionError ] = true
218380}
219381
220382module . exports = {
0 commit comments