Skip to content
This repository has been archived by the owner on Oct 28, 2020. It is now read-only.

Fix functions' callback with hardcoded 'null' as error parameter #56

Merged
merged 1 commit into from
Jan 6, 2016
Merged

Fix functions' callback with hardcoded 'null' as error parameter #56

merged 1 commit into from
Jan 6, 2016

Conversation

jsilvestre
Copy link
Contributor

The small incoherence bothered me while documenting, so I'm suggesting a fix.

@@ -82,7 +82,7 @@ class Model
# Returns null
@save: (id, data, callback) ->
@adapter.save id, data, (err, attributes) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a return callback err is missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameters are given to the callback as-is, what is missing?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that you return something when an error occurs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes sorry, I didn't realize it was up to your quote! It's fixed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry but you didn't change anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did, but since I reverted a few lines it's not showing up anymore in the diff.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, the problem is not solved. You should add a

return callback err if err

before this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh that's why I didn't understand…it seems a bit overzealous to me to do in two lines what is straightforward in one, especially since the purpose of this way of handling errors is to prevent conditional nesting, which is absent here. I'm doing the change though. Edit: fixed.

@frankrousseau
Copy link
Contributor

Thank you @jsilvestre

frankrousseau pushed a commit that referenced this pull request Jan 6, 2016
Fix functions' callback with hardcoded 'null' as error parameter
@frankrousseau frankrousseau merged commit 2e73f28 into cozy:master Jan 6, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants