Skip to content

Error object not yet documented #17

Open
@triqi

Description

@triqi

When handling errors, e.g. try {... } catch (error) { ... }, I couldn't find a definitive source of the definition of the error object. What I've done is log out the error object and added it below with my own interpretation of the object fields and what each of them means. Happy to submit a PR to update the README docs.

{
  // The error type, possible values are RequestError, StatusCodeError, TransformError
  "name": "StatusCodeError",
  // A formatted string
  "message": "{statusCode} - JSON.stringify(response.body)",
  // The full stack trace captured a the point the error is generated
  "stack": "Full stack trace",
  // The HTTP status code
  "statusCode": 404,
  // The response body (legacy?)
  "error": "",
  // The option object pass into the request
  "options": {},
  // The response object
  "response": {}
}
{
    // The error type, possible values are RequestError, StatusCodeError, TransformError
    "name": "RequestError",
    // The stringify value of the upstream error object
    "message": "cause",
    // The upstream error object
    "cause": "cause",
    // The same as the cause value (legacy?)
    "error": "cause",
    // The option object pass into the request
    "options": {},
    // The response object
    "response": {}
}
{
    // The error type, possible values are RequestError, StatusCodeError, TransformError
    "name": "TransformError",
    // The stringify value of the upstream error object
    "message": "cause",
    // The upstream error object
    "cause": "cause",
    // The same as the cause value (legacy?)
    "error": "cause",
    // The option object pass into the request
    "options": {},
    // The response object
    "response": {}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions