Show AI structure path errors in HTML5
This commit is contained in:
@@ -6,7 +6,11 @@ from typing import Any
|
||||
|
||||
from fastapi import HTTPException
|
||||
|
||||
from api_server.html5_ai_structure import render_html5_ai_structure_page, render_html5_ai_structure_result
|
||||
from api_server.html5_ai_structure import (
|
||||
render_html5_ai_structure_error,
|
||||
render_html5_ai_structure_page,
|
||||
render_html5_ai_structure_result,
|
||||
)
|
||||
from api_server.html5_forms import form_value
|
||||
|
||||
|
||||
@@ -28,8 +32,15 @@ def html5_ai_structure_run(
|
||||
input_path = form_value(form, "input_path")
|
||||
output_path = form_value(form, "output_path")
|
||||
if not input_path:
|
||||
raise HTTPException(status_code=400, detail="input_path is required")
|
||||
return render_html5_ai_structure_error("Заполните входную папку с .cf/.cfe или выгрузкой 1С.")
|
||||
if not output_path:
|
||||
raise HTTPException(status_code=400, detail="output_path is required")
|
||||
result = prepare(project_id=effective_project_id, input_path=Path(input_path), output_path=Path(output_path))
|
||||
return render_html5_ai_structure_error("Заполните папку результата.")
|
||||
try:
|
||||
result = prepare(project_id=effective_project_id, input_path=Path(input_path), output_path=Path(output_path))
|
||||
except FileNotFoundError as error:
|
||||
return render_html5_ai_structure_error(str(error))
|
||||
except PermissionError as error:
|
||||
return render_html5_ai_structure_error(f"Нет доступа к папке: {error}")
|
||||
except OSError as error:
|
||||
return render_html5_ai_structure_error(f"Ошибка файловой системы: {error}")
|
||||
return render_html5_ai_structure_result(result)
|
||||
|
||||
Reference in New Issue
Block a user