Skip to content

Commit acbda52

Browse files
api error handling
1 parent a4735ca commit acbda52

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

main.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@
123123

124124

125125
# collecting all the measures Available
126-
regexeval=[]
127126
Measures = [eval['guesses'],
128127
eval['guesses_log10'],
129128
eval['score'],
@@ -188,6 +187,7 @@
188187

189188

190189
# --- Regex Evaluations ---
190+
regexeval=[]
191191
# 1 checking for numbers
192192
pattern1 = r'(?=.*\d)'
193193
if not re.search(pattern1, pwd):
@@ -414,7 +414,7 @@
414414

415415

416416
# Fallback to Google GenAI if Ollama fails
417-
except:
417+
except Exception as ollama_error:
418418
response= google_client.models.generate_content(
419419
model="gemini-2.0-flash",
420420
contents="Generate a strong password and display only the password, no explanations, no extra text, and nothing else under any circumstances, Dont regenerate any password everytime generate a unique one and always generate minimum length of 16."
@@ -424,3 +424,6 @@
424424
st.session_state.ai_text = response.text
425425
st.rerun()
426426

427+
except:
428+
st.session_state.ai_text = "❌Failed to generate password."
429+
st.rerun()

0 commit comments

Comments
 (0)