Source code:
All Got errors contain various metadata, such as:
code
- A string likeERR_NON_2XX_3XX_RESPONSE
,options
- An instance ofOptions
,request
- An instance of Got Stream,response
(optional) - An instance of Got Response,timings
(optional) - Points toresponse.timings
.
Note:
- The
error.stack
property may look incomplete due to the execution in an async function that is triggered by a timer.- See https://stackoverflow.com/questions/54914770/is-there-a-good-way-to-surface-error-traces-in-production-across-event-emitters
Note:
- The error codes may differ when the root error has a
code
property set.
Code: ERR_GOT_REQUEST_ERROR
When a request fails. Contains a code
property with error class code, like ECONNREFUSED
. All the errors below inherit this one.
Code: ERR_CACHE_ACCESS
When a cache method fails, for example, if the database goes down or there's a filesystem error.
Code: ERR_READING_RESPONSE_STREAM
When reading from response stream fails.
Code: ERR_BODY_PARSE_FAILURE
When server response code is 2xx, and parsing body fails. Includes a response
property.
Code: ERR_UPLOAD
When the request body is a stream and an error occurs while reading from that stream.
Code: ERR_NON_2XX_3XX_RESPONSE
When the server response code is not 2xx nor 3xx if options.followRedirect
is true
, but always except for 304. Includes a response
property.
Code: ERR_TOO_MANY_REDIRECTS
When the server redirects you more than ten times. Includes a response
property.
Note:
- This error is not public.
Code: ERR_UNSUPPORTED_PROTOCOL
When given an unsupported protocol.
Code: ETIMEDOUT
When the request is aborted due to a timeout. Includes an event
(a string) property along with timings
.
Code: ERR_CANCELED
When the request is aborted with promise.cancel()
.
Code: ERR_RETRYING
Always triggers a new retry when thrown.