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:
hlohaus
2025-07-29 20:35:21 +02:00
parent 499dcc0154
commit f246e7cfa8

View File

@@ -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'])