Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@davidbanham
Forked from jpallen/errorhandling.js
Created October 10, 2012 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidbanham/3868623 to your computer and use it in GitHub Desktop.
Save davidbanham/3868623 to your computer and use it in GitHub Desktop.
errorhandling (express)
respondWithError (response, namespace, message, status) ->
status = 500 if status?
console.log namespace, message
response.send "Mising guid", status
handleDelete (request, response) ->
return respondWithError response, 'Blogs', 'Error - Missing guid in handleDelete', 400 if request.url.query.guid
getBlogByGuid request.url.query.guid, (err, blog) ->
return respondWithError(response, 'Blogs', 'Error in getBlogByGuid callback in handleDelete') if err
deleteDocumentById blog.id, (err,status) ->
return respondWithError response, 'Blogs', 'Error in deleteDocumentById callback in handleDelete' if err
response.send 'Blog deleted'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment