|
13 | 13 | from commitizen.defaults import CONFIG_FILES, DEFAULT_SETTINGS |
14 | 14 | from commitizen.exceptions import ( |
15 | 15 | InitFailedError, |
| 16 | + MissingCzCustomizeConfigError, |
16 | 17 | NoAnswersError, |
17 | 18 | ) |
18 | 19 | from commitizen.git import get_latest_tag_name, get_tag_names, smart_open |
@@ -169,16 +170,16 @@ def _ask_config_path(self) -> Path: |
169 | 170 |
|
170 | 171 | def _ask_name(self) -> str: |
171 | 172 | def construct_choice_with_description(cz_name: str) -> questionary.Choice: |
172 | | - try: |
173 | | - cz_class = registry.get(cz_name) |
174 | | - if cz_class: |
| 173 | + cz_class = registry.get(cz_name) |
| 174 | + if cz_class: |
| 175 | + try: |
175 | 176 | cz_obj = cz_class(self.config) |
176 | | - first_example = cz_obj.schema().partition("\n")[0] |
177 | | - return questionary.Choice( |
178 | | - title=cz_name, value=cz_name, description=f"{first_example}" |
179 | | - ) |
180 | | - except Exception: # pylint: disable=broad-except |
181 | | - pass |
| 177 | + except MissingCzCustomizeConfigError: |
| 178 | + return questionary.Choice(title=cz_name, value=cz_name) |
| 179 | + first_example = cz_obj.schema().partition("\n")[0] |
| 180 | + return questionary.Choice( |
| 181 | + title=cz_name, value=cz_name, description=first_example |
| 182 | + ) |
182 | 183 | return questionary.Choice(title=cz_name, value=cz_name) |
183 | 184 |
|
184 | 185 | name: str = questionary.select( |
|
0 commit comments