def task_delete(id): """Deletes a task record""" try: db.task_delete(id) except db.NotFoundException, e: return _not_found(e)
res = app.make_response('There was an error processing your request\n') res.content_encoding = 'text/plain' res.status_code = 412 return res @app.route(resource, methods=['DELETE']) def task_delete(id): """Deletes a task record""" try: db.task_delete(id) except db.NotFoundException, e: return _not_found(e) except Exception, e: return _log_and_fail(e) db.task_delete(id) res = app.make_response('') res.status_code = 204 return res @app.errorhandler(404) def _not_found(error): res = app.make_response(str(error)) res.status_code = 404 return res def _log_and_fail(error): """Funnel method for logging all unknown exceptions""" res = app.make_response(str(error))