fix: improve error handling and refactor app initialization process in HTTP handler

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Jakub Dorfman 2026-04-29 18:36:11 +02:00
parent 435be527d7
commit 197926a8a8

View file

@ -548,6 +548,7 @@ class Handler(BaseHTTPRequestHandler):
self._json(400, {"ok": False, "error": "invalid source_type"})
return
try:
result = run_panelctl(["init", name, domain, port, auth])
if not result["ok"]:
self._json(400, result)
@ -654,6 +655,9 @@ class Handler(BaseHTTPRequestHandler):
return
self._json(200, {"ok": True, "code": 0, "stdout": "initialized successfully"})
except Exception as exc:
run_panelctl(["remove", name])
self._json(500, {"ok": False, "error": f"init failed: {exc}"})
return
if len(parts) >= 3 and parts[0] == "apps":