Skip to content

Commit

Permalink
fix: Fix error handling and add exception handling for IntegrityError
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehco1996 committed Jan 17, 2024
1 parent 02c6d2b commit 7693da5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion apps/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ def post(self, request):
):
data = {"title": "修改成功!", "status": "success", "subtitle": "请及时更换客户端配置!"}
else:
data = {"title": "修改失败!", "status": "error", "subtitle": "配置更新失败!"}
data = {
"title": "修改失败!",
"status": "error",
"subtitle": "配置更新失败请重试!可能是密码太简单了",
}
return JsonResponse(data)


Expand Down
4 changes: 3 additions & 1 deletion apps/sspanel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from django.contrib.auth.models import AbstractUser
from django.core.exceptions import ValidationError
from django.core.validators import MaxValueValidator, MinValueValidator
from django.db import models, transaction
from django.db import models, transaction, IntegrityError
from django.utils import functional, timezone
from redis.exceptions import LockError

Expand Down Expand Up @@ -259,6 +259,8 @@ def update_proxy_config_from_dict(self, data):
return True
except ValidationError as e:
return False
except IntegrityError as e:
return False

def reset_traffic(self, new_traffic):
self.total_traffic = new_traffic
Expand Down

0 comments on commit 7693da5

Please sign in to comment.