@@ -156,7 +156,10 @@ def __init__(self, padding: int):
156
156
super ().__init__ (self ._message ())
157
157
158
158
def _message (self ) -> str :
159
- return f"Invalid cell padding: { self .padding } is not a positive integer."
159
+ return (
160
+ f"Invalid cell padding: The cell padding provided was { self .padding } "
161
+ f"but it must be a non-negative integer."
162
+ )
160
163
161
164
162
165
class ColumnWidthTooSmallError (TableOptionError ):
@@ -171,20 +174,34 @@ class ColumnWidthTooSmallError(TableOptionError):
171
174
min_width (int): The minimum width that is allowed
172
175
"""
173
176
174
- def __init__ (self , column_index : int , column_width : int , min_width : int ):
177
+ def __init__ (self , column_index : int , column_width : int , min_width : int | None = None ):
175
178
self .column_index = column_index
176
179
self .column_width = column_width
177
180
self .min_width = min_width
178
181
super ().__init__ (self ._message ())
179
182
180
183
def _message (self ) -> str :
181
184
return (
182
- f"Column width too small: The column width for column index { self .column_index } "
183
- f" of `column_widths` is { self .column_width } , but the minimum width "
185
+ f"Column width too small: The column width for index { self .column_index } "
186
+ f"of `column_widths` is { self .column_width } , but the minimum width "
184
187
f"required to display the content is { self .min_width } ."
185
188
)
186
189
187
190
191
+ class InvalidColumnWidthError (ColumnWidthTooSmallError ):
192
+ """Exception raised when the column width is invalid
193
+
194
+ This class is a subclass of :class:`ColumnWidthTooSmallError`.
195
+ """
196
+
197
+ def _message (self ) -> str :
198
+ return (
199
+ f"Invalid column width: The column width for index { self .column_index } "
200
+ f"of `column_widths` is { self .column_width } , but the column width "
201
+ f"must be a positive integer."
202
+ )
203
+
204
+
188
205
class InvalidAlignmentError (TableOptionError ):
189
206
"""Exception raised when an invalid value is passed for an :class:`Alignment`
190
207
0 commit comments