def write_error_message(self, stream, msg, prefix=None, log=True):
        """
        Write/print an error message to stream.
        :param stream: file to write to or None
        :type stream: file or None
        :param msg: error message
        :type msg: str
        :param log: if true, log message
        :type log: boolean
        """
        if prefix is None:
            prefix = "stash: "
        if self.debug and log:
            self.logger.debug(prefix + msg)
        if stream is None:
            self.stash.write_message(msg, error=True, prefix=prefix)
        elif stream is self.stash.io:
            if self.colored_errors:
                stream.write(self.stash.text_color(prefix + msg, "red"))
            else:
                stream.write(prefix + msg)
        else:
            stream.write(prefix + msg)

        Write/print an error message to stream.
        :param stream: file to write to or None
        :type stream: file or None
        :param msg: error message
        :type msg: str
        :param log: if true, log message
        :type log: boolean
        
system/shruntime.py