title: Gatsby build / createPages: error handling
body: <p>I'm using gatsby to build a very large site (5k+ pages, 300k+ images). The source data is unreliable (e.g. fields are often missing), which leads to errors during the <code>createPage</code> process.</p>
  
  <p>The issue is that if one single <code>createPage</code> run throws an error, the <em>entire build</em> fails. So sometimes 5k pages build successfully, then the whole thing crashes because of one error.</p>
  
  <p>I tried wrapping the page creation in a <code>try...catch</code> but it made no difference:</p>
  
  <pre class="lang-js prettyprint-override"><code>      try {
          createPage({
            path: node.slug,
            component: path.resolve(`./src/templates/BlogPost.js`),
            context: {
              id: node.id,
            },
          });
        } catch (error) {
          console.log(error);
        }
  </code></pre>
  
  <p>(I also tried checking the data at the component level and returning <code>null</code> if it's not complete, but <code>createPage</code> still creates a (blank) page, and I don't want that: <strong>I just want the page to be skipped if the data is bad</strong>)</p>
  
  <p><strong>So my question is: how can one handle errors / failed page creation during the build process so that failed pages are just skipped instead of crashing the whole build?</strong></p>
  
  <p>NB this is almost a duplicate of <a href="https://stackoverflow.com/questions/59900772/is-it-possible-to-skip-creating-a-page-during-build-if-that-page-ends-up-throwin">this question</a>, but the solution there doesn't work for me: I can't render an error page in case of bad data, I need the page to be skipped entirely if this is at all possible</p>