05/22 Enhance codes and fix bugs 2
This commit is contained in:
+10
-4
@@ -1,5 +1,9 @@
|
||||
import logging
|
||||
|
||||
from flask import Blueprint, request, jsonify, g
|
||||
from app import db, limiter, client_ip
|
||||
|
||||
_log = logging.getLogger(__name__)
|
||||
from app.models.vault_item import VaultItem, ItemType
|
||||
from app.models.folder import Folder
|
||||
from app.models.audit_log import AuditLog
|
||||
@@ -87,9 +91,10 @@ def create_item():
|
||||
ip_address=client_ip(),
|
||||
)
|
||||
db.session.commit()
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
db.session.rollback()
|
||||
return jsonify({'error': f'Database error: {str(e)}'}), 500
|
||||
_log.exception('create_item failed for user %s', g.current_user_id)
|
||||
return jsonify({'error': 'Failed to save item. Please try again.'}), 500
|
||||
return jsonify(item.to_dict()), 201
|
||||
|
||||
|
||||
@@ -148,9 +153,10 @@ def update_item(item_id):
|
||||
ip_address=client_ip(),
|
||||
)
|
||||
db.session.commit()
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
db.session.rollback()
|
||||
return jsonify({'error': f'Database error: {str(e)}'}), 500
|
||||
_log.exception('update_item failed for user %s item %s', g.current_user_id, item_id)
|
||||
return jsonify({'error': 'Failed to update item. Please try again.'}), 500
|
||||
|
||||
return jsonify(item.to_dict()), 200
|
||||
|
||||
|
||||
Reference in New Issue
Block a user