99from cppython .core .resolution import resolve_model
1010from cppython .core .schema import Interface , ProjectConfiguration , PyProject
1111from cppython .schema import API
12+ from cppython .utility .exception import ProcessError
1213
1314
1415class Project (API ):
@@ -29,8 +30,9 @@ def __init__(
2930 try :
3031 pyproject = resolve_model (PyProject , pyproject_data )
3132 except ConfigException as error :
32- self .logger .error (error , exc_info = True )
33- raise SystemExit (1 ) from None
33+ # Log the exception message explicitly
34+ self .logger .error ('Configuration error:\n %s' , error , exc_info = False )
35+ raise SystemExit ('Error: Invalid configuration. Please check your pyproject.toml.' ) from None
3436
3537 if not pyproject .tool or not pyproject .tool .cppython :
3638 self .logger .info ("The pyproject.toml file doesn't contain the `tool.cppython` table" )
@@ -69,9 +71,12 @@ def install(self) -> None:
6971
7072 try :
7173 self ._data .plugins .provider .install ()
74+ except ProcessError as error :
75+ self .logger .error ('Installation failed: %s' , error .error )
76+ raise SystemExit ('Error: Provider installation failed. Please check the logs.' ) from None
7277 except Exception as exception :
73- self .logger .error ('Provider %s failed to install ' , self . _data . plugins . provider . name ( ))
74- raise exception
78+ self .logger .error ('Unexpected error during installation: %s ' , str ( exception ))
79+ raise SystemExit ( 'Error: An unexpected error occurred during installation.' ) from None
7580
7681 self ._data .sync ()
7782
@@ -93,8 +98,11 @@ def update(self) -> None:
9398
9499 try :
95100 self ._data .plugins .provider .update ()
101+ except ProcessError as error :
102+ self .logger .error ('Update failed: %s' , error .error )
103+ raise SystemExit ('Error: Provider update failed. Please check the logs.' ) from None
96104 except Exception as exception :
97- self .logger .error ('Provider %s failed to update' , self . _data . plugins . provider . name ( ))
98- raise exception
105+ self .logger .error ('Unexpected error during update: %s ' , str ( exception ))
106+ raise SystemExit ( 'Error: An unexpected error occurred during update.' ) from None
99107
100108 self ._data .sync ()
0 commit comments