Skip to content

Make request errors have original error codes.  #37

@yezen-alnafei

Description

@yezen-alnafei

The problem
Request errors e.g. ETIMEDOUT don't have status or error code, would be nice to have so we can use them to open a circuit breaker or log out.

Suggested solution
Make transport.js add error code in createError()

createError(err, ctx) {
    const error = new Error(`Request failed for ${ctx.req.getMethod()} ${ctx.req.getUrl()}: ${err.message}`);
    error.code = err.code;
    return error;
  }

Local changes

Alternatives considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
We need to make timeout errors open our circuit breaker, as currently, we only open when we get 100+ 5xx errors. We do get the timeout error, but only as error object, with no error or status code which makes it hard to identify them, would be nice for request errors (e.g. timeout errors) to have error codes to identify them.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions