public
Last active — forked from jpallen/errorhandling.js

errorhandling (express)

  • Download Gist
errorhandling.coffee
CoffeeScript
1 2 3 4 5 6 7 8 9 10 11 12 13
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'

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.