Skip to content

Commit d04c6f2

Browse files
authored
fix: improve error messages for streamlit web app (#277)
* chore: enhance description of error msg * fix: hide error traceback for web mode * fix: handle validation error message * fix: handle error with incorrect git clone * build: update OSA version
1 parent 83c2a68 commit d04c6f2

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

osa_tool/git_agent/git_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ def clone_repository(self) -> None:
361361
)
362362
else:
363363
logger.error("An unexpected Git error occurred while cloning the repository.")
364-
raise
364+
raise Exception(f"Cannot clone the repository: {self.repo_url}") from e
365365

366366
def create_and_checkout_branch(self, branch: str = None) -> None:
367367
"""Creates and checks out a new branch.

osa_tool/run.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
from pathlib import Path
77
from typing import Optional
88

9+
from pydantic import ValidationError
10+
911
from osa_tool.aboutgen.about_generator import AboutGenerator
1012
from osa_tool.analytics.report_maker import ReportGenerator
1113
from osa_tool.analytics.sourcerank import SourceRank
@@ -174,7 +176,7 @@ def main():
174176
sys.exit(0)
175177

176178
except Exception as e:
177-
logger.error("Error: %s", e, exc_info=True)
179+
logger.error("Error: %s", e, exc_info=False if args.web_mode else True)
178180
sys.exit(1)
179181

180182
finally:
@@ -315,7 +317,11 @@ def load_configuration(
315317
"""
316318
config_loader = ConfigLoader()
317319

318-
config_loader.config.git = GitSettings(repository=repo_url)
320+
try:
321+
config_loader.config.git = GitSettings(repository=repo_url)
322+
except ValidationError as es:
323+
first_error = es.errors()[0]
324+
raise ValueError(f"{first_error["msg"]}{first_error["input"]}")
319325
config_loader.config.llm = config_loader.config.llm.model_copy(
320326
update={
321327
"api": api,

osa_tool/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def parse_git_url(repo_url: str) -> tuple[str, str, str, str]:
139139
parsed_url = urlparse(repo_url)
140140

141141
if parsed_url.scheme not in ["http", "https"]:
142-
raise ValueError(f"Unknown scheme provided: {parsed_url.scheme}")
142+
raise ValueError(f"Provided URL is not correct: {parsed_url.scheme}")
143143

144144
if not parsed_url.netloc:
145145
raise ValueError(f"Invalid Git repository URL: {parsed_url}")

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "osa_tool"
3-
version = "0.2.1.1"
3+
version = "0.2.2"
44
description = "Tool that just makes your open source project better!"
55
requires-python = ">=3.10,<4.0"
66
authors = [

0 commit comments

Comments
 (0)