Skip to content

Commit 5f078b2

Browse files
humnaawanastromancer
authored andcommitted
Updated some ValueError exceptions to throw InconsistentTableError. astropy#7413
1 parent 77b973a commit 5f078b2

5 files changed

Lines changed: 8 additions & 9 deletions

File tree

‎astropy/io/ascii/basic.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
from . import core
1616

17-
1817
class BasicHeader(core.BaseHeader):
1918
"""
2019
Basic table Header Reader
@@ -340,10 +339,10 @@ def get_cols(self, lines):
340339
self.names, raw_types = header_vals_list
341340

342341
if len(self.names) != len(raw_types):
343-
raise ValueError('RDB header mismatch between number of column names and column types')
342+
raise core.InconsistentTableError('RDB header mismatch between number of column names and column types.')
344343

345344
if any(not re.match(r'\d*(N|S)$', x, re.IGNORECASE) for x in raw_types):
346-
raise ValueError('RDB types definitions do not all match [num](N|S): {}'.format(raw_types))
345+
raise core.InconsistentTableError('RDB types definitions do not all match [num](N|S): {}'.format(raw_types))
347346

348347
self._set_cols_from_names()
349348
for col, raw_type in zip(self.cols, raw_types):

‎astropy/io/ascii/core.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,8 +651,8 @@ def check_column_names(self, names, strict_names, guessing):
651651
for name in self.colnames:
652652
if (_is_number(name) or len(name) == 0
653653
or name[0] in bads or name[-1] in bads):
654-
raise ValueError('Column name {0!r} does not meet strict name requirements'
655-
.format(name))
654+
raise InconsistentTableError('Column name {0!r} does not meet strict name requirements'
655+
.format(name))
656656
# When guessing require at least two columns
657657
if guessing and len(self.colnames) <= 1:
658658
raise ValueError('Table format guessing requires at least two columns, got {}'

‎astropy/io/ascii/daophot.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def process_lines(self, lines):
306306
outlines.append(''.join(parts))
307307
parts = []
308308
else:
309-
raise ValueError('multiline re could not match line '
309+
raise core.InconsistentTableError('multiline re could not match line '
310310
'{}: {}'.format(i, line))
311311

312312
return outlines

‎astropy/io/ascii/ecsv.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def get_cols(self, lines):
148148

149149
# Check for consistency of the ECSV vs. CSV header column names
150150
if header_names != self.names:
151-
raise ValueError('column names from ECSV header {} do not '
151+
raise core.InconsistentTableError('column names from ECSV header {} do not '
152152
'match names from header line of CSV data {}'
153153
.format(self.names, header_names))
154154

‎astropy/io/ascii/fastbasic.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,11 @@ def _read_header(self):
335335
self.engine.read_header()
336336

337337
if len(self.engine.get_names()) != len(types):
338-
raise ValueError('RDB header mismatch between number of '
338+
raise core.InconsistentTableError('RDB header mismatch between number of '
339339
'column names and column types')
340340

341341
if any(not re.match(r'\d*(N|S)$', x, re.IGNORECASE) for x in types):
342-
raise ValueError('RDB type definitions do not all match '
342+
raise core.InconsistentTableError('RDB type definitions do not all match '
343343
'[num](N|S): {0}'.format(types))
344344

345345
try_int = {}

0 commit comments

Comments
 (0)