So I was in the middle of creating a script that takes in utf-8 characters from stdin and outputs the number of bits the tree takes up + the Huffman tree + Huffman encoding of the characters. I want to use strict encoding so in the event of an unexpected character there will be a UnicodeError outputted to the console (using python 3).
I want to know what is objectively better to do in the event of a crash:

output to stdout if and only if no error will be encountered.
Or, output what has already been encoded to stdout with a UnicodeError following it (which gets printed to stderr of course)
or, it doesn't matter.
Thanks for the help IronMan: Here is a summary.
It depends:

If you need the entire data file in order to output an answer, it doesn't matter.
If you can stream the output (like file conversion), then you should error when you encounter it.
General scripting best practices when an error occurs