Skip to content

Commit

Permalink
fix(whkd): handle missing configuration file with error logging and a…
Browse files Browse the repository at this point in the history
…lert
  • Loading branch information
amnweb committed Jan 11, 2025
1 parent c27e600 commit 1b6d523
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/core/widgets/yasb/whkd.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import re
import os
import logging
from core.utils.alert_dialog import raise_info_alert
from core.widgets.base import BaseWidget
from core.validation.widgets.yasb.whkd import VALIDATION_SCHEMA
from PyQt6.QtWidgets import QLabel, QHBoxLayout, QWidget, QApplication, QSizePolicy, QVBoxLayout, QScrollArea, QPushButton, QLineEdit
Expand Down Expand Up @@ -65,6 +67,16 @@ def show_popup(self, event):
file_path = os.path.join(whkd_config_home, 'whkdrc')
else:
file_path = os.path.join(os.path.expanduser('~'), '.config', 'whkdrc')

if not os.path.exists(file_path):
logging.error(f"File not found: {file_path}")
raise_info_alert(
title=f"Error",
msg=f"The specified file does not exist\n{file_path}",
informative_msg=f"Please make sure the file exists and try again.",
rich_text=True
)
return

filtered_lines = self.read_and_filter_file(file_path)
formatted_content = self.format_content(filtered_lines)
Expand Down

0 comments on commit 1b6d523

Please sign in to comment.