Where to handle the error in a sequelize ORM query statement?
<p>I am using Sequelize ORM in Node/Express.</p>

<p>I have two tables, User and Item. Item has a foreign key linked to UserId.</p>

<p>When I try to create an Item with a UserId that is invalid (not present in Users table) a "SequelizeForeignKeyConstraintError" is thrown and leads to crashing of the application due to unhandled.</p>

<p>The problem I have is this:</p>

<p>Where do I handle the error?</p>

<p>Here is my code.</p>

<pre><code>.post(function(req,res){
        models.Item.create({
            title : req.body.title,
            UserId : req.body.UserId
        }).then(function(item){
            res.json({
                "Message" : "Created item.",
                "Item" : item
            });
        });
    });
</code></pre>