mirror of
https://github.com/xtekky/gpt4free.git
synced 2025-10-30 03:01:50 +08:00
fix: improve error messaging and handling in get_provider_models
- Updated error message formatting in `get_provider_models` call within `Backend_Api` class - Changed `MissingAuthError` handling to include exception type name in response - Added generic `Exception` catch to handle unexpected errors with HTTP 500 response - Modified `backend_api.py` file in `g4f/gui/server` directory - Ensured all returned error messages use consistent structure with exception type and message
This commit is contained in:
@@ -123,7 +123,9 @@ class Backend_Api(Api):
|
||||
try:
|
||||
response = self.get_provider_models(**kwargs)
|
||||
except MissingAuthError as e:
|
||||
return jsonify({"error": {"message": str(e)}}), 401
|
||||
return jsonify({"error": {"message": f"{type(e).__name__}: {e}"}}), 401
|
||||
except Exception as e:
|
||||
return jsonify({"error": {"message": f"{type(e).__name__}: {e}"}}), 500
|
||||
return jsonify(response)
|
||||
|
||||
@app.route('/backend-api/v2/providers', methods=['GET'])
|
||||
|
||||
Reference in New Issue
Block a user