'The `message` argument can be a single error, a list of errors, or a
dictionary that maps field names to lists of errors. What we define as
an "error" can be either a simple string or an instance of
ValidationError with its message attribute set, and what we define as
list or dictionary can be an actual `list` or `dict` or an instance
of ValidationError with its `error_list` or `error_dict` attribute set.'

def __init__(self, message, code=None, params=None):

    super().__init__(message, code, params)
    if isinstance(message, ValidationError):
        if hasattr(message, 'error_dict'):
            message = message.error_dict
        elif (not hasattr(message, 'message')):
            message = message.error_list
        else:
            (message, code, params) = (message.message, message.code, message.params)
    if isinstance(message, dict):
        self.error_dict = {}
        for (field, messages) in message.items():
            if (not isinstance(messages, ValidationError)):
                messages = ValidationError(messages)
            self.error_dict[field] = messages.error_list
    elif isinstance(message, list):
        self.error_list = []
        for message in message:
            if (not isinstance(message, ValidationError)):
                message = ValidationError(message)
            if hasattr(message, 'error_dict'):
                self.error_list.extend(sum(message.error_dict.values(), []))
            else:
                self.error_list.extend(message.error_list)
    else:
        self.message = message
        self.code = code
        self.params = params
        self.error_list = [self]
