Skip to content

Commit

Permalink
Show warning when UnicodeEncodeError is raised (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiasli authored Mar 10, 2020
1 parent 2036b78 commit 34aed7d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions knack/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ def out(self, obj, formatter=None, out_file=None): # pylint: disable=no-self-us
else:
raise
except UnicodeEncodeError:
logger.warning("Unable to encode the output with %s encoding. Unsupported characters are discarded.",
out_file.encoding)
print(output.encode('ascii', 'ignore').decode('utf-8', 'ignore'),
file=out_file, end='')

Expand Down

0 comments on commit 34aed7d

Please sign in to comment.