I have a sqlite table that has a unique constraint on one of the columns. When I run a statement that attempts to write a duplicate, an error is given in the console, but the application terminates. Can I throw the error somewhere without terminating the server? this is the code I've been using:
db.run("INSERT INTO companies (company, location) VALUES (?,?)", [ input.name, input.location ], function(err){
if(err) throw err;
});
With the console logging:
node/db.js:6
if(err) throw err;
^
Error: SQLITE_CONSTRAINT: UNIQUE constraint failed: companies.company
You could if you use something like domains possibly. However, typically what is done is you pass the error to a callback (e.g. if (err) return callback(err);) that is passed in to the function containing your db.run().