Redesign exception pattern to conditional
@@ -17,17 +17,13 @@ class CreateUserController():
password = UserModel.generate_hash(user['password'])
)
- try:
- new_user.save_to_db()
+ if not new_user.save_to_db():
+ return NoContent, 500
new_role = RoleModel(
name='user',
user_id=new_user.id
)
- try:
- new_role.save_to_db()
- except:
- return NoContent, 500
- except:
+ if not new_role.save_to_db():
return NoContent, 500
