Skip to content

Commit

Permalink
fix: Improve error message for _sort_summary_list failures (#243)
Browse files Browse the repository at this point in the history
mansenfranzen authored Apr 5, 2024
1 parent 461be30 commit 87923a1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions sphinxcontrib/autodoc_pydantic/directives/autodocumenters.py
Original file line number Diff line number Diff line change
@@ -569,15 +569,15 @@ def sort_func(name: str) -> int:
# catch cases where field is not found in tagorder
msg = f'Field {name} in {self.object_name} not found in tagorder'
raise ValueError(msg)
else:

try:
return sorted(names, key=sort_func)
except TypeError as e:
msg = (
f'Invalid value `{sort_order}` provided for '
f'`summary_list_order`. Valid options are: '
f'{OptionsSummaryListOrder.values()}'
f'Uncaught exception while sorting fields for model'
f'{self.object_name} with sort order {sort_order}.'
)
raise ValueError(msg)

return sorted(names, key=sort_func)
raise ValueError(msg).with_traceback(e.__traceback__) from e

def _get_field_summary_line(self, field_name: str) -> str:
"""Get reST for field summary for given `member_name`."""

0 comments on commit 87923a1

Please sign in to comment.