jimguys/cuddlychang — pull request #5 by marclitchfield (2013-09-14 08:18:38+00:00)
Title: Implemented error handling pattern in repositories and routes.

**In repositories**:
Introduced a shared module (common_repository) that exposes functions to standardize error handling, so we do not need to put error handling machinery in each repository method. The result is more concise than explicit error checking machinery, but I feel it is still a bit complicated, especially the handleQueryResponse function. An alternative idea might be to introduce a "query" method that would accept the SQL query, query parameters, and a success callback.

**In routes (poems.js)**:
Introduced "respond" method to standardize on the convention that unhandled errors result in an HTTP 500 error, and the error details are logged to the console.