def write_error()

in transcoder/message/ErrorWriter.py [0:0]


    def write_error(self, raw_record, message: ParsedMessage, exception: Exception):
        """Write data about error to file"""
        if self.file is None:
            exists = os.path.exists(self.output_path)
            if not exists:
                os.makedirs(self.output_path)

            # Only create error file if errors exist
            self.file = open(self.__get_file_name(self.prefix, 'out'),  # pylint: disable=consider-using-with
                             mode='w', encoding='utf-8')
            self.file.write('time, message_type, message_name, failed_step, exception, data\n')

        encoded = self.__encode_source_message(raw_record)
        ex_str = str(exception).replace('\r', '').replace('\n', '').replace(',', ' ')
        epoch_time = time.time()
        current_step = f'{self.step}-{self.note}'
        if message is not None:
            out_str = f'{epoch_time}, {message.type}, {message.name}, {current_step}, {ex_str}, '
        else:
            out_str = f'{epoch_time},,, {self.step}, {ex_str}, '
        self.file.write(out_str + encoded + '\n')