forked from 3wordchant/capsul-flask
fix potential exceptions in error handler
This commit is contained in:
parent
b32db058f0
commit
0320bb5e29
@ -141,9 +141,12 @@ def handle_create(operation_id, request_body):
|
||||
)
|
||||
except:
|
||||
error_message = my_exec_info_message(sys.exc_info())
|
||||
params = f"email='{request_body['email']}', id='{request_body['id']}', "
|
||||
params = f"{params}, template_image_file_name='{request_body['template_image_file_name']}', vcpus='{request_body['vcpus']}'"
|
||||
params = f"{params}, memory_mb='{request_body['memory_mb']}', ssh_authorized_keys='{request_body['ssh_authorized_keys']}'"
|
||||
params = f"email='{request_body['email'] if 'email' in request_body else 'KeyError'}', "
|
||||
params= f"{params} id='{request_body['id'] if 'id' in request_body else 'KeyError'}', "
|
||||
params= f"{params} template_image_file_name='{request_body['template_image_file_name'] if 'template_image_file_name' in request_body else 'KeyError'}', "
|
||||
params= f"{params} vcpus='{request_body['vcpus'] if 'vcpus' in request_body else 'KeyError'}', "
|
||||
params= f"{params} memory_mb='{request_body['memory_mb'] if 'memory_mb' in request_body else 'KeyError'}', "
|
||||
params= f"{params} ssh_authorized_keys='{request_body['ssh_authorized_keys'] if 'ssh_authorized_keys' in request_body else 'KeyError'}', "
|
||||
current_app.logger.error(f"spoke_model.create({params}) failed: {error_message}")
|
||||
return jsonify(dict(assignment_status=assignment_status, error_message=error_message))
|
||||
|
||||
@ -162,7 +165,9 @@ def handle_destroy(operation_id, request_body):
|
||||
current_app.config['SPOKE_MODEL'].destroy(id=request_body['id'], email=request_body['email'])
|
||||
except:
|
||||
error_message = my_exec_info_message(sys.exc_info())
|
||||
current_app.logger.error(f"current_app.config['SPOKE_MODEL'].destroy(id='{request_body['id']}', email='{request_body['email']}') failed: {error_message}")
|
||||
params = f"email='{request_body['email'] if 'email' in request_body else 'KeyError'}', "
|
||||
params= f"{params} id='{request_body['id'] if 'id' in request_body else 'KeyError'}', "
|
||||
current_app.logger.error(f"current_app.config['SPOKE_MODEL'].destroy({params}) failed: {error_message}")
|
||||
return jsonify(dict(assignment_status="assigned", status="error", error_message=error_message))
|
||||
|
||||
return jsonify(dict(assignment_status="assigned", status="success"))
|
||||
@ -184,7 +189,10 @@ def handle_vm_state_command(operation_id, request_body):
|
||||
current_app.config['SPOKE_MODEL'].vm_state_command(id=request_body['id'], email=request_body['email'], command=request_body['command'])
|
||||
except:
|
||||
error_message = my_exec_info_message(sys.exc_info())
|
||||
current_app.logger.error(f"current_app.config['SPOKE_MODEL'].vm_state_command(id='{request_body['id']}', email='{request_body['email']}, command='{request_body['command']}') failed: {error_message}")
|
||||
params = f"email='{request_body['email'] if 'email' in request_body else 'KeyError'}', "
|
||||
params= f"{params} id='{request_body['id'] if 'id' in request_body else 'KeyError'}', "
|
||||
params= f"{params} command='{request_body['command'] if 'command' in request_body else 'KeyError'}', "
|
||||
current_app.logger.error(f"current_app.config['SPOKE_MODEL'].vm_state_command({params}) failed: {error_message}")
|
||||
return jsonify(dict(assignment_status="assigned", status="error", error_message=error_message))
|
||||
|
||||
return jsonify(dict(assignment_status="assigned", status="success"))
|
Loading…
Reference in New Issue
Block a user