Skip to content

Commit

Permalink
clean-tsv: Improve --sort-col error message
Browse files Browse the repository at this point in the history
The existing error message prints the python ValueError after the
helpful, custom error message we've written. This can easily get lost
on the user. Because there's no real need to share the underlying error
(since this error is pretty well scoped), stop printing it to stderr.
  • Loading branch information
kairstenfay committed Sep 3, 2020
1 parent bbc760e commit ea09281
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions bin/clean-tsv
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ def clean_tsv_file(input_file, output_file, n_cols, header, sort_col):
if not header:
sort_col = int(sort_col)
col_names.remove(sort_col)
except ValueError as e:
print(f"{sort_col} is not a column name in file, or if --no-header was used, there are not this many columns in the file.")
raise e
except ValueError:
raise ValueError(f"«{sort_col}» is not a column name in file, or if --no-header was "
"used, there are not this many columns in the file.")
col_names = [sort_col] + col_names
data = data.sort_values(col_names)
data.to_csv(output_file, sep="\t", index=False, header=header, quoting=csv.QUOTE_NONE)
Expand Down

0 comments on commit ea09281

Please sign in to comment.