diff --git a/api/apps/canvas_app.py b/api/apps/canvas_app.py index f353db6765..aa49aa226d 100644 --- a/api/apps/canvas_app.py +++ b/api/apps/canvas_app.py @@ -19,7 +19,7 @@ from flask_login import login_required, current_user from api.db.services.canvas_service import CanvasTemplateService, UserCanvasService from api.utils import get_uuid -from api.utils.api_utils import get_json_result, server_error_response, validate_request +from api.utils.api_utils import get_json_result, server_error_response, validate_request, get_data_error_result from agent.canvas import Canvas from peewee import MySQLDatabase, PostgresqlDatabase @@ -61,7 +61,7 @@ def save(): return server_error_response(ValueError("Duplicated title.")) req["id"] = get_uuid() if not UserCanvasService.save(**req): - return server_error_response("Fail to save canvas.") + return get_data_error_result(retmsg="Fail to save canvas.") else: UserCanvasService.update_by_id(req["id"], req) @@ -73,7 +73,7 @@ def save(): def get(canvas_id): e, c = UserCanvasService.get_by_id(canvas_id) if not e: - return server_error_response("canvas not found.") + return get_data_error_result(retmsg="canvas not found.") return get_json_result(data=c.to_dict()) @@ -85,7 +85,7 @@ def run(): stream = req.get("stream", True) e, cvs = UserCanvasService.get_by_id(req["id"]) if not e: - return server_error_response("canvas not found.") + return get_data_error_result(retmsg="canvas not found.") if not isinstance(cvs.dsl, str): cvs.dsl = json.dumps(cvs.dsl, ensure_ascii=False) @@ -151,7 +151,7 @@ def reset(): try: e, user_canvas = UserCanvasService.get_by_id(req["id"]) if not e: - return server_error_response("canvas not found.") + return get_data_error_result(retmsg="canvas not found.") canvas = Canvas(json.dumps(user_canvas.dsl), current_user.id) canvas.reset()