What is the good way to break from promise chain?
<p>I am wondering how can I properly break promise chain in JS.</p>

<p>In this code, I am connecting to database at first, then I am checking if collection already has some data, if not add them. Don't pay attention to some actionhero.js code..it does not matter here.</p>

<p>The main question is: <strong>Is it okay to break chain using throw null?</strong></p>

<pre><code>mongoose.connect(api.config.mongo.connectionURL, {})
        .then(() =&gt; {
            return api.mongo.City.count();
        })
        .then(count =&gt; {
            if (count !== 0) {
                console.log(`Amout of cities is ${count}`);
                throw null; // break from chain method. Is it okay ?
            }
            return api.mongo.City.addCities(api.config.mongo.dataPath + '/cities.json');
        })
        .then(cities =&gt; {
            console.log("Cities has been added");
            console.log(cities);
            next();
        })
        .catch(err =&gt; {
            next(err);
        })
</code></pre>

<p>Many thanks!</p>