From 2715a5a339a7cbb61286e8090097409db1fefa3a Mon Sep 17 00:00:00 2001 From: jyong <718720800@qq.com> Date: Thu, 6 Jun 2024 18:31:14 +0800 Subject: [PATCH] optimize firecrawl error msg --- api/controllers/console/auth/data_source_bearer_auth.py | 3 ++- api/controllers/console/auth/error.py | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 api/controllers/console/auth/error.py diff --git a/api/controllers/console/auth/data_source_bearer_auth.py b/api/controllers/console/auth/data_source_bearer_auth.py index 14fc1197c6ddb5..eddb67f4bc30b9 100644 --- a/api/controllers/console/auth/data_source_bearer_auth.py +++ b/api/controllers/console/auth/data_source_bearer_auth.py @@ -1,6 +1,7 @@ from flask_login import current_user from flask_restful import Resource, reqparse from werkzeug.exceptions import Forbidden +from controllers.console.auth.error import ApiKeyAuthFailedError from controllers.console import api from libs.login import login_required @@ -42,7 +43,7 @@ def post(self): try: ApiKeyAuthService.create_provider_auth(current_user.current_tenant_id, args) except Exception as e: - return {'error': str(e)}, 500 + raise ApiKeyAuthFailedError(str(e)) return {'result': 'success'}, 200 diff --git a/api/controllers/console/auth/error.py b/api/controllers/console/auth/error.py new file mode 100644 index 00000000000000..c55ff8707d224f --- /dev/null +++ b/api/controllers/console/auth/error.py @@ -0,0 +1,7 @@ +from libs.exception import BaseHTTPException + + +class ApiKeyAuthFailedError(BaseHTTPException): + error_code = 'auth_failed' + description = "{message}" + code = 500