throw appropriate error message