Throw error instead of assert for consistency