|
17 | 17 | from module_renderer import ModuleRenderer |
18 | 18 | from plain2code_arguments import parse_arguments |
19 | 19 | from plain2code_console import console |
20 | | -from plain2code_exceptions import InternalServerError, InvalidFridArgument, MissingAPIKey, PlainSyntaxError |
| 20 | +from plain2code_exceptions import ( |
| 21 | + ConflictingRequirements, |
| 22 | + CreditBalanceTooLow, |
| 23 | + InternalServerError, |
| 24 | + InvalidFridArgument, |
| 25 | + LLMInternalError, |
| 26 | + MissingAPIKey, |
| 27 | + MissingResource, |
| 28 | + PlainSyntaxError, |
| 29 | + UnexpectedState, |
| 30 | +) |
21 | 31 | from plain2code_logger import ( |
22 | 32 | CrashLogHandler, |
23 | 33 | IndentedFormatter, |
@@ -205,7 +215,7 @@ def render(args, run_state: RunState, codeplain_api, event_bus: EventBus): # no |
205 | 215 | return |
206 | 216 |
|
207 | 217 |
|
208 | | -def main(): |
| 218 | +def main(): # noqa: C901 |
209 | 219 | args = parse_arguments() |
210 | 220 |
|
211 | 221 | event_bus = EventBus() |
@@ -253,12 +263,28 @@ def main(): |
253 | 263 | dump_crash_logs(args) |
254 | 264 | except MissingAPIKey as e: |
255 | 265 | console.error(f"Missing API key: {str(e)}\n") |
256 | | - except InternalServerError: |
| 266 | + except (InternalServerError, UnexpectedState) as e: |
257 | 267 | console.error( |
258 | | - f"Internal server error.\n\nPlease report the error to support@codeplain.ai with the attached {args.log_file_name} file." |
| 268 | + f"Internal server error: {str(e)}.\n\nPlease report the error to support@codeplain.ai with the attached {args.log_file_name} file." |
259 | 269 | ) |
260 | 270 | console.debug(f"Render ID: {run_state.render_id}") |
261 | 271 | dump_crash_logs(args) |
| 272 | + except ConflictingRequirements as e: |
| 273 | + console.error(f"Conflicting requirements: {str(e)}\n") |
| 274 | + console.debug(f"Render ID: {run_state.render_id}") |
| 275 | + dump_crash_logs(args) |
| 276 | + except CreditBalanceTooLow as e: |
| 277 | + console.error(f"Credit balance too low: {str(e)}\n") |
| 278 | + console.debug(f"Render ID: {run_state.render_id}") |
| 279 | + dump_crash_logs(args) |
| 280 | + except LLMInternalError as e: |
| 281 | + console.error(f"LLM internal error: {str(e)}\n") |
| 282 | + console.debug(f"Render ID: {run_state.render_id}") |
| 283 | + dump_crash_logs(args) |
| 284 | + except MissingResource as e: |
| 285 | + console.error(f"Missing resource: {str(e)}\n") |
| 286 | + console.debug(f"Render ID: {run_state.render_id}") |
| 287 | + dump_crash_logs(args) |
262 | 288 | except Exception as e: |
263 | 289 | console.error(f"Error rendering plain code: {str(e)}\n") |
264 | 290 | console.debug(f"Render ID: {run_state.render_id}") |
|
0 commit comments