Fix bare except clauses for better error handling
Replace 5 bare except clauses with 'except Exception:' to improve error handling and prevent catching system exits and keyboard interrupts: - gui.py:155 - Queue event processing - setup_wizard.py:184 - API response parsing - test_credentials.py:213 - Response JSON parsing - test_credentials.py:240 - Error response parsing - test_credentials.py:257 - Response text formatting This change improves code quality and follows Python best practices for exception handling.
This commit is contained in:
parent
2795178a75
commit
d3f2fa43c3
3 changed files with 5 additions and 5 deletions
2
gui.py
2
gui.py
|
|
@ -152,7 +152,7 @@ class Dashboard:
|
||||||
try:
|
try:
|
||||||
msg = self.event_queue.get_nowait()
|
msg = self.event_queue.get_nowait()
|
||||||
self.window["-LOG-"].print(msg)
|
self.window["-LOG-"].print(msg)
|
||||||
except:
|
except Exception:
|
||||||
break
|
break
|
||||||
|
|
||||||
# Update statistics
|
# Update statistics
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,7 @@ async def validate_perplexity_key(api_key, model="sonar-pro"):
|
||||||
print_warning(f"400 Fehler: {error_msg}")
|
print_warning(f"400 Fehler: {error_msg}")
|
||||||
print_info("Fahre trotzdem fort - bitte später manuell prüfen!")
|
print_info("Fahre trotzdem fort - bitte später manuell prüfen!")
|
||||||
return (True, False, model)
|
return (True, False, model)
|
||||||
except:
|
except Exception:
|
||||||
print_warning(f"Unerwartete Antwort: {response.status_code}")
|
print_warning(f"Unerwartete Antwort: {response.status_code}")
|
||||||
print_info("Fahre trotzdem fort - bitte später manuell prüfen!")
|
print_info("Fahre trotzdem fort - bitte später manuell prüfen!")
|
||||||
return (True, False, model)
|
return (True, False, model)
|
||||||
|
|
|
||||||
|
|
@ -210,7 +210,7 @@ async def test_perplexity_key(api_key, model="sonar-pro"):
|
||||||
if "choices" in data and len(data["choices"]) > 0:
|
if "choices" in data and len(data["choices"]) > 0:
|
||||||
content = data["choices"][0]["message"]["content"]
|
content = data["choices"][0]["message"]["content"]
|
||||||
print_info(f"Test response: '{content}'")
|
print_info(f"Test response: '{content}'")
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return True, test_model
|
return True, test_model
|
||||||
|
|
@ -237,7 +237,7 @@ async def test_perplexity_key(api_key, model="sonar-pro"):
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
print_info(f"Error details: {error_msg}")
|
print_info(f"Error details: {error_msg}")
|
||||||
except:
|
except Exception:
|
||||||
print_warning(f"400 Bad Request (couldn't parse error)")
|
print_warning(f"400 Bad Request (couldn't parse error)")
|
||||||
|
|
||||||
# If this was the last model, fail
|
# If this was the last model, fail
|
||||||
|
|
@ -254,7 +254,7 @@ async def test_perplexity_key(api_key, model="sonar-pro"):
|
||||||
print_warning(f"Unexpected status code: {response.status_code}")
|
print_warning(f"Unexpected status code: {response.status_code}")
|
||||||
try:
|
try:
|
||||||
print_info(f"Response: {response.text[:200]}")
|
print_info(f"Response: {response.text[:200]}")
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Try next model if available
|
# Try next model if available
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue