def write_error(request, code, message):
 error = {'error': {'code': code, 'message': message}}
 request.set_status(code)
 request.write(json.dumps(error))

def write_error ( request , code , message ) : error = { 'error' : { 'code' : code , 'message' : message } } request . set_status ( code ) request . write ( json . dumps ( error ) )
sets the response headers and body for error messages .