def get_valid_error(x1, x2=-1):
    """
    Function that validates:

    * x1 is possible to convert to numpy array

    * x2 is possible to convert to numpy array (if exists)

    * x1 and x2 have the same length (if both exist)
    """
    # just error
    if type(x2) == int and x2 == -1:
        try:    
            e = np.array(x1)
        except:
            raise ValueError('Impossible to convert series to a numpy array')        
    # two series
    else:
        try:
            x1 = np.array(x1)
            x2 = np.array(x2)
        except:
            raise ValueError('Impossible to convert one of series to a numpy array')
        if not len(x1) == len(x2):
            raise ValueError('The length of both series must agree.')
        e = x1 - x2
    return e
Function that validates:

    * x1 is possible to convert to numpy array

    * x2 is possible to convert to numpy array (if exists)

    * x1 and x2 have the same length (if both exist)