Skip to content

Commit

Permalink
fix #3: more descriptive exception text when iostream instance does n…
Browse files Browse the repository at this point in the history
…ot match
  • Loading branch information
chfw committed Sep 8, 2015
1 parent 901e899 commit 8408f79
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pyexcel_io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
MESSAGE_LOADING_FORMATTER,
MESSAGE_ERROR_02,
MESSAGE_ERROR_03,
MESSAGE_WRONG_IO_INSTANCE,
MESSAGE_CANNOT_WRITE_STREAM_FORMATTER,
MESSAGE_CANNOT_READ_STREAM_FORMATTER,
MESSAGE_CANNOT_WRITE_FILE_TYPE_FORMATTER,
Expand Down Expand Up @@ -138,7 +139,7 @@ def load_data(filename,
if validate_io(file_type, filename):
content = filename
else:
raise IOError(MESSAGE_ERROR_03)
raise IOError(MESSAGE_WRONG_IO_INSTANCE)
else:
io = get_io(file_type)
if not PY2:
Expand Down Expand Up @@ -195,7 +196,7 @@ def get_writer(filename, file_type=None, **keywords):
extension = file_type
to_memory = True
if not validate_io(file_type, filename):
raise IOError(MESSAGE_ERROR_03)
raise IOError(MESSAGE_WRONG_IO_INSTANCE)
else:
raise IOError(MESSAGE_ERROR_03)
elif is_string(type(filename)):
Expand Down
1 change: 1 addition & 0 deletions pyexcel_io/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
MESSAGE_INVALID_PARAMETERS = "Invalid parameters"
MESSAGE_ERROR_02 = "No content, file name. Nothing is given"
MESSAGE_ERROR_03 = "cannot handle unknown content"
MESSAGE_WRONG_IO_INSTANCE = "Wrong io instance is passed for your file format."
MESSAGE_CANNOT_WRITE_STREAM_FORMATTER = "Cannot write content of file type %s to stream"
MESSAGE_CANNOT_READ_STREAM_FORMATTER = "Cannot read content of file type %s from stream"
MESSAGE_CANNOT_WRITE_FILE_TYPE_FORMATTER = "Cannot write content of file type %s to file %s"
Expand Down

0 comments on commit 8408f79

Please sign in to comment.