FossilRepo

Add error handling to ticket_comment view

ragelink 2026-04-08 13:47 trunk
Commit a14edfaab9ae321655d4a754dc8f6ea90f905d113bb787f2616c336414738842
1 file changed +13 -8
+13 -8
--- fossil/views.py
+++ fossil/views.py
@@ -1439,18 +1439,23 @@
14391439
project, fossil_repo, reader = _get_repo_and_reader(slug, request, "write")
14401440
14411441
if request.method == "POST":
14421442
comment = request.POST.get("comment", "").strip()
14431443
if comment:
1444
- from fossil.cli import FossilCLI
1445
-
1446
- cli = FossilCLI()
1447
- success = cli.ticket_change(fossil_repo.full_path, ticket_uuid, {"icomment": comment})
1448
- if success:
1449
- from django.contrib import messages
1450
-
1451
- messages.success(request, "Comment added.")
1444
+ from django.contrib import messages
1445
+
1446
+ try:
1447
+ from fossil.cli import FossilCLI
1448
+
1449
+ cli = FossilCLI()
1450
+ success = cli.ticket_change(fossil_repo.full_path, ticket_uuid, {"icomment": comment})
1451
+ if success:
1452
+ messages.success(request, "Comment added.")
1453
+ else:
1454
+ messages.error(request, "Failed to add comment.")
1455
+ except Exception:
1456
+ messages.error(request, "Failed to add comment.")
14521457
from django.shortcuts import redirect
14531458
14541459
return redirect("fossil:ticket_detail", slug=slug, ticket_uuid=ticket_uuid)
14551460
14561461
14571462
--- fossil/views.py
+++ fossil/views.py
@@ -1439,18 +1439,23 @@
1439 project, fossil_repo, reader = _get_repo_and_reader(slug, request, "write")
1440
1441 if request.method == "POST":
1442 comment = request.POST.get("comment", "").strip()
1443 if comment:
1444 from fossil.cli import FossilCLI
1445
1446 cli = FossilCLI()
1447 success = cli.ticket_change(fossil_repo.full_path, ticket_uuid, {"icomment": comment})
1448 if success:
1449 from django.contrib import messages
1450
1451 messages.success(request, "Comment added.")
 
 
 
 
 
1452 from django.shortcuts import redirect
1453
1454 return redirect("fossil:ticket_detail", slug=slug, ticket_uuid=ticket_uuid)
1455
1456
1457
--- fossil/views.py
+++ fossil/views.py
@@ -1439,18 +1439,23 @@
1439 project, fossil_repo, reader = _get_repo_and_reader(slug, request, "write")
1440
1441 if request.method == "POST":
1442 comment = request.POST.get("comment", "").strip()
1443 if comment:
1444 from django.contrib import messages
1445
1446 try:
1447 from fossil.cli import FossilCLI
1448
1449 cli = FossilCLI()
1450 success = cli.ticket_change(fossil_repo.full_path, ticket_uuid, {"icomment": comment})
1451 if success:
1452 messages.success(request, "Comment added.")
1453 else:
1454 messages.error(request, "Failed to add comment.")
1455 except Exception:
1456 messages.error(request, "Failed to add comment.")
1457 from django.shortcuts import redirect
1458
1459 return redirect("fossil:ticket_detail", slug=slug, ticket_uuid=ticket_uuid)
1460
1461
1462

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button