mirror of https://github.com/langgenius/dify.git
refactor: update error handling to use BadRequest for plugin invocation errors
This commit is contained in:
parent
e2543bcf30
commit
2842cbf1e1
|
|
@ -6,7 +6,7 @@ from typing import cast
|
|||
from flask import abort, request
|
||||
from flask_restx import Resource, fields, inputs, marshal_with, reqparse
|
||||
from sqlalchemy.orm import Session
|
||||
from werkzeug.exceptions import Forbidden, InternalServerError, NotFound
|
||||
from werkzeug.exceptions import BadRequest, Forbidden, InternalServerError, NotFound
|
||||
|
||||
import services
|
||||
from controllers.console import api, console_ns
|
||||
|
|
@ -992,7 +992,7 @@ class DraftWorkflowTriggerRunApi(Resource):
|
|||
except InvokeRateLimitError as ex:
|
||||
raise InvokeRateLimitHttpError(ex.description)
|
||||
except PluginInvokeError as e:
|
||||
raise ValueError(e.to_user_friendly_error())
|
||||
raise BadRequest(e.to_user_friendly_error())
|
||||
except Exception as e:
|
||||
logger.exception("Error polling trigger debug event")
|
||||
raise e
|
||||
|
|
@ -1050,7 +1050,7 @@ class DraftWorkflowTriggerNodeApi(Resource):
|
|||
)
|
||||
event = poller.poll()
|
||||
except PluginInvokeError as e:
|
||||
return jsonable_encoder({"status": "error", "error": e.to_user_friendly_error()}), 500
|
||||
return jsonable_encoder({"status": "error", "error": e.to_user_friendly_error()}), 400
|
||||
except Exception as e:
|
||||
logger.exception("Error polling trigger debug event")
|
||||
raise e
|
||||
|
|
@ -1074,7 +1074,7 @@ class DraftWorkflowTriggerNodeApi(Resource):
|
|||
logger.exception("Error running draft workflow trigger node")
|
||||
return jsonable_encoder(
|
||||
{"status": "error", "error": "An unexpected error occurred while running the node."}
|
||||
), 500
|
||||
), 400
|
||||
|
||||
|
||||
@console_ns.route("/apps/<uuid:app_id>/workflows/draft/trigger/run-all")
|
||||
|
|
@ -1151,4 +1151,4 @@ class DraftWorkflowTriggerRunAllApi(Resource):
|
|||
{
|
||||
"status": "error",
|
||||
}
|
||||
), 500
|
||||
), 400
|
||||
Loading…
Reference in New Issue