def custom_error_exception(error=None, exception=None):
    """Define custom exceptions for MySQL server errors

    This function defines custom exceptions for MySQL server errors and
    returns the current set customizations.

    If error is a MySQL Server error number, then you have to pass also the
    exception class.

    The error argument can also be a dictionary in which case the key is
    the server error number, and value the exception to be raised.

    If none of the arguments are given, then custom_error_exception() will
    simply return the current set customizations.

    To reset the customizations, simply supply an empty dictionary.

    Examples:
        import mysql.connector
        from mysql.connector import errorcode

        # Server error 1028 should raise a DatabaseError
        mysql.connector.custom_error_exception(
            1028, mysql.connector.DatabaseError)

        # Or using a dictionary:
        mysql.connector.custom_error_exception({
            1028: mysql.connector.DatabaseError,
            1029: mysql.connector.OperationalError,
            })

        # Reset
        mysql.connector.custom_error_exception({})

    Returns a dictionary.
    """
    global _CUSTOM_ERROR_EXCEPTIONS
    if isinstance(error, dict) and not error:
        _CUSTOM_ERROR_EXCEPTIONS = {}
        return _CUSTOM_ERROR_EXCEPTIONS
    if not error and not exception:
        return _CUSTOM_ERROR_EXCEPTIONS
    if not isinstance(error, (int, dict)):
        raise ValueError(
            'The error argument should be either an integer or dictionary')
    if isinstance(error, int):
        error = {error: exception}
    for errno, _exception in error.items():
        if not isinstance(errno, int):
            raise ValueError('error number should be an integer')
        try:
            if not issubclass(_exception, Exception):
                raise TypeError
        except TypeError:
            raise ValueError('exception should be subclass of Exception')
        _CUSTOM_ERROR_EXCEPTIONS[errno] = _exception
    return _CUSTOM_ERROR_EXCEPTIONS
