Code Monkey home page Code Monkey logo

Comments (11)

analog-nico avatar analog-nico commented on July 28, 2024

Hi @jakecraige its a valid point. However, I would prefer not to break the backwards-compatibility so I would introduce a new option flag with which you could turn this different rejection on.

Thinking outside the box maybe adding a .toString() to the rejection object would also work?

from request-promise.

JSteunou avatar JSteunou commented on July 28, 2024

@analog-nico I'm sorry but rejecting with an Error Object is the standard way to do.

from request-promise.

tyabonil avatar tyabonil commented on July 28, 2024

We can extend the error object in the reject. That said, what practical usecases are you being blocked for?  


Ty

On Wed, Feb 4, 2015 at 2:27 PM, Nicolai Kamenzky [email protected]
wrote:

Hi @jakecraige its a valid point. However, I would prefer not to break the backwards-compatibility so I would introduce a new option flag with which you could turn this different rejection on.

Thinking outside the box maybe adding a .toString() to the rejection object would also work?

Reply to this email directly or view it on GitHub:
#38 (comment)

from request-promise.

analog-nico avatar analog-nico commented on July 28, 2024

@JSteunou I am completely with you. However, IMO we also need to consider the existing users who overlook a breaking chance notice when updating. We would actually mess with their error recovery code... Anyway, we should look forward as @tyabonil says.

I would say the following code would not break backward-compatibility since the Error objects have the same properties as the objects in the current implementation:

    if (err) {

        self._rp_reject(_.assign(new RequestError(String(err)), {
            error: err,
            options: self._rp_options,
            response: response
        }));

    } else if (self._rp_options.simple && !(/^2/.test('' + response.statusCode))) {

        self._rp_reject(_.assign(new StatusCodeError(response.statusCode + ' - ' + body), {
            error: body,
            options: self._rp_options,
            response: response,
            statusCode: response.statusCode
        }));

    }

Would that cover your use cases?

from request-promise.

JSteunou avatar JSteunou commented on July 28, 2024

semver can prevent breaking changes updates.

from request-promise.

analog-nico avatar analog-nico commented on July 28, 2024

@JSteunou Being realistic people may still overlook breaking changes. And those who don't should not need to migrate a whole lot. I hope my proposed solution can meet all interests. Does it meet yours?

from request-promise.

analog-nico avatar analog-nico commented on July 28, 2024

@jakecraige Does my proposed solution meet your needs? In the first case Mocha would display the stack trace starting from the code in Request-Promise not the one of the err returned by Request. I hope that is fine.

from request-promise.

jakecraige avatar jakecraige commented on July 28, 2024

@analog-nico That solution sounds good to me. It would fix the issue I'm seeing and maintain backwards compat 👍

from request-promise.

analog-nico avatar analog-nico commented on July 28, 2024

I just published version 0.4.0 to npm.

from request-promise.

jakecraige avatar jakecraige commented on July 28, 2024

Looks great. Thanks for taking care of this @analog-nico !

from request-promise.

analog-nico avatar analog-nico commented on July 28, 2024

You are welcome. If anything comes up feel free to ping me on Gitter or open another issue.

from request-promise.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.