Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

err object is not 'null' it is 'undefined' #40

Closed
kennethgreen opened this issue Jun 25, 2013 · 2 comments
Closed

err object is not 'null' it is 'undefined' #40

kennethgreen opened this issue Jun 25, 2013 · 2 comments

Comments

@kennethgreen
Copy link

The doco says that for the callbacks, if everything went OK then the err object will be null. However it is not 'null' it is 'undefined'. I have confirmed this for ensureIndex() but I think it is in most of not all cases.

The behaviour of the 'err' object should be as consistent as possible and the doco should be as clear and accurate as possible. So I recommend choosing either 'null' or 'undefined' and ensuring that the 'err' object is always the same value in the 'success' case for all API calls and that the doco states the correct value.

Thanks for this useful library.

@louischatriot
Copy link
Owner

Good idea, I just pushed a new version where in all successful calls, err is null. That said, the best way to check for success is to use if (err) { ... } and not if (err === null) { ... } so that even if it is undefined the code is still valid.

@kennethgreen
Copy link
Author

Great, thank you. You are right about if (err) { ... }.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants