|
2 | 2 | import re |
3 | 3 | import sys |
4 | 4 |
|
| 5 | +from typing import TYPE_CHECKING |
5 | 6 | from typing import Dict |
6 | 7 | from typing import List |
7 | 8 | from typing import Optional |
|
37 | 38 | from .ui.ui import UI |
38 | 39 |
|
39 | 40 |
|
| 41 | +if TYPE_CHECKING: |
| 42 | + from crashtest.solution_providers.solution_provider_repository import ( |
| 43 | + SolutionProviderRepository, |
| 44 | + ) |
| 45 | + |
| 46 | + |
40 | 47 | class Application: |
41 | 48 | """ |
42 | 49 | An Application is the container for a collection of commands. |
@@ -70,6 +77,10 @@ def __init__(self, name: str = "console", version: str = "") -> None: |
70 | 77 |
|
71 | 78 | self._command_loader: Optional[CommandLoader] = None |
72 | 79 |
|
| 80 | + self._solution_provider_repository: Optional[ |
| 81 | + "SolutionProviderRepository" |
| 82 | + ] = None |
| 83 | + |
73 | 84 | @property |
74 | 85 | def name(self) -> str: |
75 | 86 | return self._name |
@@ -160,6 +171,11 @@ def catch_exceptions(self, catch_exceptions: bool = True) -> None: |
160 | 171 | def is_single_command(self) -> bool: |
161 | 172 | return self._single_command |
162 | 173 |
|
| 174 | + def set_solution_provider_repository( |
| 175 | + self, solution_provider_repository: "SolutionProviderRepository" |
| 176 | + ) -> None: |
| 177 | + self._solution_provider_repository = solution_provider_repository |
| 178 | + |
163 | 179 | def add(self, command: Command) -> Optional[Command]: |
164 | 180 | self._init() |
165 | 181 |
|
@@ -473,7 +489,9 @@ def create_io( |
473 | 489 | def render_error(self, error: Exception, io: IO) -> None: |
474 | 490 | from cleo.ui.exception_trace import ExceptionTrace |
475 | 491 |
|
476 | | - trace = ExceptionTrace(error) |
| 492 | + trace = ExceptionTrace( |
| 493 | + error, solution_provider_repository=self._solution_provider_repository |
| 494 | + ) |
477 | 495 | trace.render(io.error_output, isinstance(error, CleoSimpleException)) |
478 | 496 |
|
479 | 497 | def _configure_io(self, io: IO) -> None: |
|
0 commit comments