def write(self, dictionary, serializer=None):
        """
        Add the dictionary to list of messages.
        """
        # Validate copy of the dictionary, to ensure what we store isn't
        # mutated.
        try:
            self._validate_message(dictionary.copy(), serializer)
        except Exception as e:
            # Skip irrelevant frames that don't help pinpoint the problem:
            from . import _output, _message, _action

            skip_filenames = [_output.__file__, _message.__file__, _action.__file__]
            for frame in inspect.stack():
                if frame[1] not in skip_filenames:
                    break
            self._failed_validations.append(
                "{}: {}".format(e, "".join(traceback.format_stack(frame[0])))
            )
        self.messages.append(dictionary)
        self.serializers.append(serializer)
        if serializer is TRACEBACK_MESSAGE._serializer:
            self.tracebackMessages.append(dictionary)