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

[WIP][Bug 890538] Update API handling & response codes for the Login server #140

Closed
wants to merge 5 commits into from

Conversation

sedge
Copy link
Contributor

@sedge sedge commented Aug 6, 2013

res.json( 404, { error: err || "User not found for ID: " + id } );
return;
metrics.increment( "user.get.error" );
throw new Error( "Database helper failure" );
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems odd to me to mix json error code returns on the response with throwing exceptions--you can't really have it both ways.

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 see what you mean. I built the user.js controller architecture to assume the errors have all been processed by the individual SQL and MONGO handles. It was the only way I could think of to de-couple that logic from this controller.

I supposed I could just return 500 in the case that a more specific error object isn't available?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I'd send back a 500 with some info. If you have an interface that deals with json responses, you have to follow-through on that for every path, not just the success paths.

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, I remember why I did this now. If this error triggers, there is /no/ information available other than the fact that something went wrong.

All errors that CAN be caught have already been processed, so its a signal that something... very very odd has happened. Returning a 500 still makes sense, but I get the feeling there should be something else too.

What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say just 500 on the response here rather than throw.

How does this affect login API calls with emails that aren't webmakers? This happens often because of the legacy popcorn and thimble makes that we added to the Make API.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its backwards compatible for email as _id

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking at this again, I'm not sure I know what you mean @cadecairos

@jbuck jbuck closed this Feb 13, 2014
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.

4 participants