Skip to content

Instantly share code, notes, and snippets.

@vincicat
Last active August 24, 2023 09:34
Show Gist options
  • Save vincicat/fead52142aa8887e88fdd1d943235f6c to your computer and use it in GitHub Desktop.
Save vincicat/fead52142aa8887e88fdd1d943235f6c to your computer and use it in GitHub Desktop.
axios default error messages (v1.x)

Axios Message and error code

Message code
"Request aborted" ECONNABORTED
"Network Error" ERR_NETWORK
config.timeoutErrorMessage transitional.clarifyTimeoutError ? ETIMEDOUT : ECONNABORTED
"timeout exceeded" transitional.clarifyTimeoutError ? ETIMEDOUT : ECONNABORTED
"timeout of " + config.timeout + "ms exceeded" transitional.clarifyTimeoutError ? ETIMEDOUT : ECONNABORTED
"Unsupported protocol " + protocol + ":" ERR_BAD_REQUEST
"Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream" ERR_BAD_REQUEST
"Request body larger than maxBodyLength limit" ERR_BAD_REQUEST
"Request failed with status code " + response.status response.status = 4xx : ERR_BAD_REQUEST, response.status = 5xx : ERR_BAD_RESPONSE
Adapter ${nameOrAdapter} is not supported by the environment ERR_NOT_SUPPORT
"error trying to parse `config.timeout` to int" ERR_BAD_OPTION_VALUE
"[Axios v" + VERSION + "] Transitional option "" + opt + """ + " has been removed" + (version ? " in " + version : "") + (message ? ". " + message : "") (empty)
"options must be an object" ERR_BAD_OPTION_VALUE
"option " + opt + " must be " + result ERR_BAD_OPTION_VALUE
"Unknown option " + opt ERR_BAD_OPTION
"Invalid URL" ERR_INVALID_URL
"Blob is not supported" ERR_NOT_SUPPORT
"Unsupported protocol " + protocol ERR_NOT_SUPPORT
"Blob is not supported. Use a Buffer instead." (empty)

remark:

  • transitional.clarifyTimeoutError(false) - throw ETIMEDOUT error instead of generic ECONNABORTED on request timeouts
  • (empty) message refer to programming error which should not be seen by user.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment