def generate_exception(err_code):
  """
  Return a EigenMatException object based on the error code err_code.
  """

  if err_code == -1:
    return EigenMatException("Incompatible matrix dimensions.")
  elif err_code == -2:
    return EigenMatException("CUBLAS error.")
  elif err_code == -3:
    return EigenMatException("CUDA error: " + get_last_cuda_error())
  elif err_code == -4:
    return EigenMatException("Operation not supported on views.")
  elif err_code == -5:
    return EigenMatException("Operation not supported on transposed matrices.")
  elif err_code == -6:
    return EigenMatException("")
  elif err_code == -7:
    return EigenMatException("Incompatible transposedness.")
  elif err_code == -8:
    return EigenMatException("Matrix is not in device memory.")
  elif err_code == -9:
    return EigenMatException("Operation not supported.")

  Return a EigenMatException object based on the error code err_code.
  
eigenmat/eigenmat.py