Skip to content

Commit 30ab07d

Browse files
fix(screens): sanitize file read and save error messages
1 parent d90cf73 commit 30ab07d

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

src/edit_python_pe/markdown_builder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ def load_file_into_form(
6565
try:
6666
content = _read_file(path_md)
6767
except Exception as e:
68+
import logging
69+
logging.getLogger(__name__).exception("Error reading file %s", filename, exc_info=e)
6870
member_app.exit(
69-
message=_("Error reading file {filename}: {error}").format(
70-
filename=filename, error=e
71-
)
71+
message=_("Error reading file {filename}").format(filename=filename)
7272
)
7373
return
7474

src/edit_python_pe/screens/save_loading.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,21 @@ def perform_save(self) -> None:
8282
self.pr_url = pr_url
8383
self.app.call_from_thread(self.show_success, message)
8484
except Exception as e:
85-
error_message = str(e)
85+
github_error_detail = str(e)
8686
try:
8787
if isinstance(e, GithubException) and getattr(e, "data", None):
8888
errors = e.data.get("errors", [])
8989
if errors and isinstance(errors, list):
90-
error_message = errors[0].get(
90+
github_error_detail = errors[0].get(
9191
"message", e.data.get("message", str(e))
9292
)
9393
else:
94-
error_message = e.data.get("message", str(e))
94+
github_error_detail = e.data.get("message", str(e))
95+
logger.error("Error creating PR: %s", github_error_detail, exc_info=e)
9596
except Exception:
96-
logger.error("Failed to extract GithubException details", exc_info=True)
97+
logger.error("Failed to extract GithubException details", exc_info=e)
98+
99+
error_message = _("An error occurred while saving. Please try again.")
97100
self.app.call_from_thread(self.show_error, error_message)
98101

99102
def show_success(self, message: str) -> None:

0 commit comments

Comments
 (0)