GithubHelp home page GithubHelp logo

Hello documentation? about node-oauth HOT 13 CLOSED

ciaranj avatar ciaranj commented on July 23, 2024
Hello documentation?

from node-oauth.

Comments (13)

ciaranj avatar ciaranj commented on July 23, 2024

Um, say-what ? There is a single commit (3c45927) that isn't in the published npm package (0.9.5) [and it has nothing to do with the constructor] Have you tried the wiki which has examples in it ?

from node-oauth.

demian85 avatar demian85 commented on July 23, 2024

oauth.js is totally different after an npm installation. I cloned it with git and now it works.

from node-oauth.

ciaranj avatar ciaranj commented on July 23, 2024

I've re-tested this morning 'npm install oauth' installs exactly the same version of the library as the 0.9.5 tag in the repository.. I'm utterly at a loss as to how you experienced this issue?

from node-oauth.

demian85 avatar demian85 commented on July 23, 2024

oauth or node-oauth?? which is the package name?? i installed node-oauth

from node-oauth.

ciaranj avatar ciaranj commented on July 23, 2024

'oauth' presumably someone has added a new library of 'node-oauth' which goes against the npm naming standards :( how nice of them ;)

from node-oauth.

demian85 avatar demian85 commented on July 23, 2024

Sorry but i don't know where to ask for basic things...
Can you explain which type of error the method get() receives as the first argument? it seems i'm getting a different one every time. Sometimes i get an Error instance and sometimes i get a custom object with "statusCode" and stuff.
Could you please follow node standards and send en Error instance as the first parameter?? I would like to log "err.message"...

from node-oauth.

ciaranj avatar ciaranj commented on July 23, 2024

FWIW I'm unaware of any such node 'standard', I'm interested in the details if you can point me at it? In any case, yes these are the 2 types of 'error' you will receive.

In the case of a node/stream/connection level error you will receive node's underlying (Javascript) Error object that you can log.

The OTHER error case is not an error in the node sense, but an error in the OAuth sense, in this case you will receive an object literal that consists of the 2 parts; 'statusCode' and 'data' where 'statusCode' is the HTTP status received from the server (likely a 4xx or 5xx) and 'data' is the response stream that had been received, if any.

from node-oauth.

demian85 avatar demian85 commented on July 23, 2024

And how am I supposed to know which is the case?
Don't you think that sending always an Error instance makes more sense?
Take a look around, 99% of node modules handle callback errors that way.

from node-oauth.

ciaranj avatar ciaranj commented on July 23, 2024

If ( error && error.statusCode) {
// Oauth issue
}
else if (error) {
// node problem
}

from node-oauth.

demian85 avatar demian85 commented on July 23, 2024

Omg you are a genius, that must be the most optimum solution ever. Why
nobody does it like that? Oh wait, maybe because what I told you is the best
solution?
El 05/09/2011 03:03, "ciaranj" <
[email protected]>
escribi:

If ( error && error.statusCode) {
// Oauth issue
}
else if (error) {
// node problem
}

On Monday, September 5, 2011, demian85 <
[email protected]>
wrote:

And how am I supposed to know which is the case?
Don't you think that sending always an Error instance makes more sense?
Take a look around, 99% of node modules handle callback errors that way.

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

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

from node-oauth.

ciaranj avatar ciaranj commented on July 23, 2024

Ok, so lets say that we decide that an error object is returned, how do you propose distinguishing between the two types of error case in this situation?

(Given I accept fully that error handling in node is generally a bit klunky, passing an error as the first argument will never be the optimum case)

from node-oauth.

demian85 avatar demian85 commented on July 23, 2024

var e = new Error("everything is broken!");
e.statusCode = 404;
e.someShit = "asdf"
callback(e);

That way i can always log e.message
El 05/09/2011 08:38, "ciaranj" <
[email protected]>
escribi:

Ok, so lets say that we decide that an error object is returned, how do
you propose distinguishing between the two types of error case in this
situation?

(Given I accept fully that error handling in node is generally a bit
klunky, passing an error as the first argument will never be the optimum
case)

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

from node-oauth.

ciaranj avatar ciaranj commented on July 23, 2024

I get that your requirement is that you can always 'log message' and using an error object would give you that (also adding a message property to the passed back object literal would do this too, always happy to accept patches)

My question however was given your assertion with regards to my suggestion for dealing with the extreme and burdenous complexity of dealing with two different 'types' coming back in the error callback how would you deal with it differently, as far as I can tell you'd need the exact same code (which apparently is the least optimum solution?)

Also, as with all my libraries ...which I write for my own purposes and share in case they're useful to others.... node-oauth is MIT licensed so you're welcome to fork it and make it so the error comes back in a form you're more comfortable dealing with.

I cannot (will not) change the returned error object to be an 'Error' as that will quite likely break any existing code out there that depends on the type inference to act appropriately. But as stated above if you want to submit a pull request for adding a message property to the returned object so your logging code only uses a single if-null guard, rather than if-null-and-message guard then I'm more than happy to accept it :)

from node-oauth.

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.