Created — forked from jpallen/errorhandling.js

Embed URL


SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

errorhandling (express)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
respondWithError (response, namespace, message, status) ->
status = 500 if status?
console.log namespace, message
response.setHeader 'Content-Type', 'application/json'
response.writeHead status
response.end JSON.stringify("Missing guid")
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, (err,status) ->
return respondWithError response, 'Blogs', 'Error in deleteDocumentById callback in handleDelete' if err
response.writeHead 200
response.end 'Blog deleted'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.