Skip to content

Commit 44be37a

Browse files
committed
refactor: improve error handling and logging across multiple files
This commit enhances error handling and logging practices in several files: 1. Replace print statements with logging calls for better error tracking 2. Use logging.error instead of print for consistency in error reporting 3. Update rich-click configuration to use the correct namespace These changes improve the overall robustness and maintainability of the code.
1 parent e45f91f commit 44be37a

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

src/wellcode_cli/github/github_format_ai.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import logging
23
import re
34

45
from anthropic import Anthropic
@@ -166,9 +167,9 @@ def get_ai_analysis(all_metrics):
166167
return message.content[0].text if message.content else ""
167168

168169
except Exception as e:
169-
print(f"Unexpected error in get_ai_analysis: {str(e)}")
170-
print("Error type:", type(e).__name__)
170+
logging.error(f"Unexpected error in get_ai_analysis: {str(e)}")
171+
logging.error("Error type:", type(e).__name__)
171172
import traceback
172173

173-
print("Traceback:", traceback.format_exc())
174+
logging.error("Traceback:", traceback.format_exc())
174175
return ""

src/wellcode_cli/github/github_metrics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ def update_time_metrics(pr, commits, repo_metrics, org_metrics, start_date, end_
362362
org_metrics.prs_merged_to_main / days_in_period
363363
)
364364
except Exception as e:
365-
print(f"DEBUG: Error in update_time_metrics: {str(e)}")
365+
logging.error(f"Error in update_time_metrics: {str(e)}")
366366
# Continue processing even if there's an error with one PR
367367
pass
368368

src/wellcode_cli/linear/linear_metrics.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import logging
12
from datetime import datetime, timedelta
23

34
import requests
@@ -89,7 +90,7 @@ def get_linear_metrics(start_date, end_date, user_filter=None) -> LinearOrgMetri
8990
data = response.json()
9091

9192
if "errors" in data:
92-
print("Error in Linear API response:", data["errors"])
93+
logging.error("Error in Linear API response:", data["errors"])
9394
raise RuntimeError(f"Linear API error: {data['errors']}")
9495

9596
issues_data = data["data"]["issues"]

src/wellcode_cli/main.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
from .commands import chat, chat_interface, completion, config, report, review
99

1010
# Configure rich-click
11-
click.USE_RICH_MARKUP = True
12-
click.USE_MARKDOWN = True
13-
click.SHOW_ARGUMENTS = True
14-
click.GROUP_ARGUMENTS_OPTIONS = True
15-
click.STYLE_ERRORS_SUGGESTION = "yellow italic"
16-
click.ERRORS_SUGGESTION = "Try '--help' for more information."
11+
click.rich_click.USE_RICH_MARKUP = True
12+
click.rich_click.USE_MARKDOWN = True
13+
click.rich_click.SHOW_ARGUMENTS = True
14+
click.rich_click.GROUP_ARGUMENTS_OPTIONS = True
15+
click.rich_click.STYLE_ERRORS_SUGGESTION = "yellow italic"
16+
click.rich_click.ERRORS_SUGGESTION = "Try '--help' for more information."
1717

1818
# Initialize rich console
1919
console = Console()

0 commit comments

Comments
 (0)