Get the :class:`language_tags.Tag.Tag.Error` of a specific Tag error code.
        The error creates a message explaining the error.
        It also refers to the respective (sub)tag(s).

        :param int code: a Tag error error:

            * 1 = Tag.ERR_DEPRECATED
            * 2 = Tag.ERR_NO_LANGUAGE
            * 3 = Tag.ERR_UNKNOWN,
            * 4 = Tag.ERR_TOO_LONG
            * 5 = Tag.ERR_EXTRA_REGION
            * 6 = Tag.ERR_EXTRA_EXTLANG
            * 7 = Tag.ERR_EXTRA_SCRIPT,
            * 8 = Tag.ERR_DUPLICATE_VARIANT
            * 9 = Tag.ERR_WRONG_ORDER
            * 10 = Tag.ERR_SUPPRESS_SCRIPT,
            * 11 = Tag.ERR_SUBTAG_DEPRECATED
            * 12 = Tag.ERR_EXTRA_LANGUAGE

        :param subtag: string (sub)tag or list of string (sub)tags creating the error.
        :return: An exception class containing: a Tag error input code, the derived message with the given (sub)tag(s).
            input

def error(self, code, subtag=None):
        """
        Get the :class:`language_tags.Tag.Tag.Error` of a specific Tag error code.
        The error creates a message explaining the error.
        It also refers to the respective (sub)tag(s).

        :param int code: a Tag error error:

            * 1 = Tag.ERR_DEPRECATED
            * 2 = Tag.ERR_NO_LANGUAGE
            * 3 = Tag.ERR_UNKNOWN,
            * 4 = Tag.ERR_TOO_LONG
            * 5 = Tag.ERR_EXTRA_REGION
            * 6 = Tag.ERR_EXTRA_EXTLANG
            * 7 = Tag.ERR_EXTRA_SCRIPT,
            * 8 = Tag.ERR_DUPLICATE_VARIANT
            * 9 = Tag.ERR_WRONG_ORDER
            * 10 = Tag.ERR_SUPPRESS_SCRIPT,
            * 11 = Tag.ERR_SUBTAG_DEPRECATED
            * 12 = Tag.ERR_EXTRA_LANGUAGE

        :param subtag: string (sub)tag or list of string (sub)tags creating the error.
        :return: An exception class containing: a Tag error input code, the derived message with the given (sub)tag(s).
            input
        """
        message = ""
        data = self.data

        if code == self.ERR_DEPRECATED:
            message = 'The tag %s is deprecated.' % data['tag']

            # Note that a record that contains a 'Deprecated' field and no corresponding 'Preferred-Value' field
            # has no replacement mapping (RFC 5646 section 3.1.6).
            if 'Preferred-Value' in self.data['record']:
                message += ' Use \'%s\' instead.' % data['record']['Preferred-Value']

        elif code == self.ERR_SUBTAG_DEPRECATED:
            message = 'The subtag \'%s\' is deprecated.' % subtag.format

        elif code == self.ERR_NO_LANGUAGE:
            if not len(data['tag']):
                message = 'Empty tag.'
            else:
                message = 'Missing language tag in \'%s\'.' % data['tag']

        elif code == self.ERR_UNKNOWN:
            message = 'Unknown code \'%s\'' % subtag

        elif code == self.ERR_TOO_LONG:
            message = 'The private-use subtag \'%s\' is too long.' % subtag

        elif code in [self.ERR_EXTRA_LANGUAGE,
                    self.ERR_EXTRA_EXTLANG,
                    self.ERR_EXTRA_REGION,
                    self.ERR_EXTRA_SCRIPT]:
            message = 'Extra %s subtag \'%s\' found.' % (subtag.type, subtag.format)

        elif code == self.ERR_DUPLICATE_VARIANT:
            message = 'Duplicate variant subtag \'%s\' found.' % subtag.format

        elif code == self.ERR_WRONG_ORDER:
            message = 'The subtag \'%s\' should not appear before \'%s\'.' % (subtag[0].format, subtag[1].format)

        elif code == self.ERR_SUPPRESS_SCRIPT:
            message = 'The script subtag \'%s\' is the same as the language suppress-script.' % subtag.format

        class Error(Exception):
            def __init__(self, code, message, tag, subtag):
                self.code = code
                self.message = message
                self.tag = tag
                self.subtag = subtag.format if isinstance(subtag, Subtag) else subtag

            def __str__(self):
                return repr("%s: %s (Tag %s; Subtag %s)" % (self.code, self.message, self.tag, str(self.subtag)))

        return Error(code, message, data['tag'], subtag)