Skip to content

Commit 945ebfd

Browse files
refactor: replace broad exception handling with specific error types in summarize and tts modules
1 parent b63f6b6 commit 945ebfd

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

modules/summarize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def generate_summary(text, sentence_count=3):
3535
parser = PlaintextParser.from_string(text, Tokenizer("english"))
3636
summarizer = LsaSummarizer()
3737
summary = summarizer(parser.document, sentence_count)
38-
except (ValueError, AttributeError, Exception) as e:
38+
except (ValueError, AttributeError, TypeError) as e:
3939
logger.error("❌ Error generating summary: %s", e)
4040
return "An error occurred while generating the summary."
4141

modules/tts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def speak(text):
3030
engine = pyttsx3.init()
3131
engine.say(text)
3232
engine.runAndWait()
33-
except (RuntimeError, Exception) as e:
33+
except (RuntimeError) as e:
3434
logger.error("❌ Failed to speak text: %s", e)
3535
return
3636

0 commit comments

Comments
 (0)