Skip to content

Commit 78a752d

Browse files
Merge pull request #437 from SiddharthaSree/feat/user-friendly-errors-379
feat: add user-friendly error messages
2 parents 1a3f04d + f3ce0af commit 78a752d

File tree

5 files changed

+784
-5
lines changed

5 files changed

+784
-5
lines changed

src/pieces/app.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from pieces.config.constants import PIECES_DATA_DIR
77
from pieces.config.migration import run_migration
8+
from pieces.errors import format_error
89
from pieces.headless.exceptions import HeadlessError
910
from pieces.headless.models.base import ErrorCode
1011
from pieces.headless.output import HeadlessOutput
@@ -171,7 +172,11 @@ def main():
171172
else:
172173
Settings.logger.critical(e, ignore_sentry=True)
173174
try:
174-
Settings.show_error("UNKNOWN EXCEPTION", e)
175+
# Display user-friendly error message
176+
friendly_message = format_error(e, include_technical=False)
177+
Settings.logger.console_error.print(f"[red]{friendly_message}[/red]")
178+
if not Settings.run_in_loop:
179+
sys.exit(2)
175180
except SystemExit:
176181
sentry_sdk.flush(2)
177182
raise

src/pieces/errors/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""
2+
User-friendly error handling for Pieces CLI.
3+
4+
This module provides utilities for transforming technical error messages
5+
into helpful, actionable messages for users.
6+
"""
7+
8+
from .user_friendly import (
9+
UserFriendlyError,
10+
ErrorCategory,
11+
format_error,
12+
get_user_friendly_message,
13+
)
14+
15+
__all__ = [
16+
"UserFriendlyError",
17+
"ErrorCategory",
18+
"format_error",
19+
"get_user_friendly_message",
20+
]

0 commit comments

Comments
 (0)